Hi all,
Pretty new to VBA here. I have a Macro (below) that has a hardcoded cell reference ('BB'!A3), but I want to delete that and be able to input whatever cell reference needed when I'm running the Macro for different worksheets. This is the hardcoded version:
1. I've been experimenting with InputBox, but apparently because the cell reference is used in a couple of formulae as you can see above, it doesn't work.
2. I was getting an error that went away when I declared the cell variable as a Variant. Is that the correct type?
3. Please note that the above code doesn't show my attempts with InputBox for the cell reference (the "i" variable is separate).
I'd appreciate any insight!
Pretty new to VBA here. I have a Macro (below) that has a hardcoded cell reference ('BB'!A3), but I want to delete that and be able to input whatever cell reference needed when I'm running the Macro for different worksheets. This is the hardcoded version:
VBA Code:
Sub Test1()
Dim i As Integer
i = Application.InputBox("Confirm the number of days the resource worked in this period")
For i = 1 To i
Cells(i, 2).Select
Selection.Formula = "=[B]'BB'!A3[/B]"
Cells(i, 3).Select
Selection.Value = "8"
Cells(i, 6).Select
Selection.Value = Format(Cells(i, 1).Value, "mm/dd/yyyy")
Selection.NumberFormat = "dd\/mm\/yyyy"
Cells(i, 15).Select
Selection.Formula = "=TRIM(RIGHT(SUBSTITUTE([B]'BB'!A3[/B],"" "", REPT("" "",100)),100))"
Cells(i, 1).Select
Selection.Value = "ApBiBo" & Cells(i, 15).Value & Cells(i, 1).Value
Cells(i, 15).Value = ""
Next i
End Sub
1. I've been experimenting with InputBox, but apparently because the cell reference is used in a couple of formulae as you can see above, it doesn't work.
2. I was getting an error that went away when I declared the cell variable as a Variant. Is that the correct type?
3. Please note that the above code doesn't show my attempts with InputBox for the cell reference (the "i" variable is separate).
I'd appreciate any insight!