I am trying to use the following code to insert values into the input boxes on a page. I am trying to insert the values into the "input" cells as if I were reading a book. So from left to right. Right now I have hardcoded a column to the far right with "X". Is there any way to stop the Do and move to the next row and then repeat until all the input boxes within a range are filled? The range changes with each time I would run the Macro, so I don't always know the last column or last row. So I use LastCol, LastRow to figure those out. The code below will move me to F3 from F2 but I need to continue down column F until the LastRow variable is met.
Any help or guidance would greatly be appreciated.The red code is where I need the most help.
Dim LastCol As String
LastCol = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
Dim LastRow As Long
With Worksheets("Layout Numbering")
LastRow = .Cells(.Rows.Count, "G").End(xlUp).Row
End With
Dim LastRowA As Long
With Worksheets("Layout Numbering")
LastRowA = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Range("AZ1").Select
ActiveCell.FormulaR1C1 = "X"
Selection.AutoFill Destination:=Range("AZ1:AZ" & LastRow), Type:=xlFillDefault
Dim iCol As Integer 'Scratch- Column Number
Range("F2").Select
For iCol = 0 To LastRowA - 1
Do
Selection.Offset(0, 1).Select
Loop Until Selection.Style = "Input" Or ActiveCell = "X"
If Selection.Style = "Input" Then
ActiveCell.FormulaR1C1 = iCol
Else: Range("F" & Cells(Rows.Count, "F").End(xlUp).Row + 1).Offset(1, 0).Select
End If
Next iCol
End Sub
Any help or guidance would greatly be appreciated.The red code is where I need the most help.
Dim LastCol As String
LastCol = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
Dim LastRow As Long
With Worksheets("Layout Numbering")
LastRow = .Cells(.Rows.Count, "G").End(xlUp).Row
End With
Dim LastRowA As Long
With Worksheets("Layout Numbering")
LastRowA = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Range("AZ1").Select
ActiveCell.FormulaR1C1 = "X"
Selection.AutoFill Destination:=Range("AZ1:AZ" & LastRow), Type:=xlFillDefault
Dim iCol As Integer 'Scratch- Column Number
Range("F2").Select
For iCol = 0 To LastRowA - 1
Do
Selection.Offset(0, 1).Select
Loop Until Selection.Style = "Input" Or ActiveCell = "X"
If Selection.Style = "Input" Then
ActiveCell.FormulaR1C1 = iCol
Else: Range("F" & Cells(Rows.Count, "F").End(xlUp).Row + 1).Offset(1, 0).Select
End If
Next iCol
End Sub