Is there a way to activate any cell and make it active in the worksheet at anytime in the program? Kept geting this error, Application-defined or object-defined error, when I do the following:
Function numbCols(countrows) As Integer
Dim shtAnnual As Worksheet
Dim rng As Range
Dim numCols As Integer
Dim txtInbox As String
Set shtAnnual = ActiveSheet
'activate the first cell as a starting point for counting non-empty rows
shtAnnual.Cells(1, 1).Activate
'Set r1 to the active cell
Set rng = ActiveCell
'Loop until an empty cell is found.
Do While rng.Value <> ""
numCols = numCols + 1
'Get a new range two rows below the current one.
Set rng = rng.Offset(0, 1)
Loop
numbCols = numCols
shtAnnual.Cells(0, numbCols + 1).Activate
Set rng = ActiveCell
txtInbox = InputBox("Result Column", "Parse Result", "Please enter what column name you want for the result column")
rng.Cells = txtInbox
End Function
The error occured on this line: shtAnnual.Cells(0, numbCols + 1).Activate.
Any help is appreciated.
ljCharlie
Bookmarks