data type mismatch error when refer to Excel cell using variables
I have a for loop to go through the rows of a Excel sheet. If I refer to a cell like this:
If objXLBook.ActiveSheet.Range("a1").Value = TextToSearch Then
IT WORKS FINE
If I do the same statement using variables for the A and 1 address of cell, I get a data type mismatch error. I have done coding like this before and never had any problems. maybe I am missing or forgetting something??? My code is below
Dim rownum as integer
dim colNum as string
Rownum = 1
colNum = "a"
If objXLBook.ActiveSheet.Range(colNum + rownum).Value = TextToSearch Then
Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.