
Originally Posted by
Logit
.
Option Explicit
Sub Test1()
Dim x As Integer
Dim NumRows As Integer
Dim Cell As Range
' Set numrows = number of rows of data.
NumRows = Range("A2", Range("A2").End(xlDown)).Rows.Count
' Select cell a1.
Range("A2").Select
' Establish "For" loop to loop "numrows" number of times.
For x = 2 To NumRows
Cells(x, 1).Select
'Place print code here using "Selection.Value" as the reference to the term
'to be printed on the invoice.
MsgBox Selection.Value 'use this for demo purpose
' Selects cell down 1 row from active cell.
ActiveCell.Offset(1, 0).Select
Next
End Sub
Gracias, tu codigo me dio la idea de como hacerle, muchas gracias.
use un loop que me cambie el valor de la celda que ocupo asi imprime el siguente valor solo que como tengo formulas en las celdas use un if para detectar los que estan en blanco
o se puede directamente sin usar un "if"?
Sub Test1()
Dim x As Integer
Dim NumRows As Integer
Dim Cell As Range
' Set numrows = number of rows of data.
NumRows = Range("I2", Range("I2").End(xlDown)).Rows.Count
' Select cell a1.
' Establish "For" loop to loop "numrows" number of times.
For x = 2 To NumRows
Cells(x, 9).Select
If Selection.Value <> "" Then
Range("B31").Value = Selection.Value
MsgBox Selection.Value
' ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=False, IgnorePrintAreas:=False
ActiveCell.Offset(1, 0).Select
'Place print code here using "Selection.Value" as the reference to the term
'to be printed on the invoice.
'use this for demo purpose
' Selects cell down 1 row from active cell.
Else
Exit Sub
End If
Next
End Sub
Bookmarks