Jump to content
Tecnoruc

Saltar celdas en blanco en VBA

Recommended Posts

Hola!

Tengo el siguiente codigo VBA asociado a una macro y no he logrado agregar una linea para saltar todas las celdas que se encuentren en blanco sin terminar mi macro, me pueden ayudar por favor?

Basicamente busco que al correr la siguiente linea, el codigo sepa que cuenado la celda esta vacia, se debe pasar a la siguiente celda sin enviar un 0 ni otro valor. 

Set valueCell = Worksheets("WritePI").Cells(i + 2, 2)

 

Codigo:

Sub put_data3()
   Dim i As Integer
   Dim numoftags As Integer
   
   'The following four variables are arguments to PIPutVal()
   Dim sTagname As String  'Tagname
   Dim stime As String     'Timestamp
   Dim valueCell As Range  'Cell reference containing value to be written
   Dim resultCell As Range 'Cell reference to hold result
   Dim sServer3 As String   'PI3 server name
   Dim apierr As Long
   Dim rowstr As String
   Dim buf As String
   Dim Timeval As Double
   
   Dim macroResult As Variant
   Dim timeCell As Range 'Cell reference to hold time of putval
   
   
   i = 0
   numoftags = 20 'Define number of tags that will receive data
   
   'Define cell storing desired timestamp
stime = Worksheets("Configuration").Cells(7, 7).Text
   

   'Define Server's cell
   sServer3 = Worksheets("Configuration").Cells(9, 3).Text
   i = 0
   While i < numoftags
      'Confirmation Message
      Set resultCell = Worksheets("WritePI").Cells(i + 2, 3)
      'Tag Names
    sTagname = Worksheets("WritePI").Cells(i + 2, 1).Text
    'Values to be sent to PI
    Set valueCell = Worksheets("WritePI").Cells(i + 2, 2)
      
macroResult = Application.Run("PIPutValx", sTagname, valueCell, stime, sServer3, resultCell)
        
      'move down to the row number
      i = i + 1
Wend

Call ReadFromPI 'Macro


End Sub

CODIGO FUNCIONAL.txt

Share this post


Link to post
Share on other sites



×
×
  • Create New...

Important Information

Privacy Policy