Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 382
  • Last Modified:

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
end if
 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
end if
0
LeLeBrown
Asked:
LeLeBrown
1 Solution
 
NorieData ProcessorCommented:
Replace + with &.
0
 
LeLeBrownAuthor Commented:
That Worked.
Thanks
0

Featured Post

Hire Technology Freelancers with Gigs

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now