While writing a VBA macro I have tried to select a certain cell by storing both the column letter and the row number separately then putting them together with range(X + Y).select however it is not accepting the number half of it (it does work if I just manually type the number that's stored). Is there a certain way I need to store the number or write it for it be accepted?
I'm getting Type Mismatch in the debug so I'm assuming I've used the wrong word somewhere for something.
Teaching myself excel VBA currently so apologies if it's an easy error that I have just missed.
A simplified version without the extra fluff like named sheets ect. basically looks like below
Dim NVCurrRN As Integer Dim Prod As Variant Prod = "B" Sheets("Sheet2").Select Range("B1").Select ActiveCell.Offset(1, 0).Select NVCurrRN = ActiveCell.Row Range(Prod + NVCurrRN).Select
When looking at it while debugging Prod = "B" correctly and NVCurrRN = 2, I have tried various other ways trying to get it to work but couldn't work it out though I'm sure I've used something similar in the past with no issues.
(This is taking place in a loop if that changes anything, the error shows on the first run though so I don't think there is any issue with that portion.)
https://stackoverflow.com/questions/66575141/issue-using-range-select-in-excel-vba-macro-when-calling-both-locations-from-som March 11, 2021 at 09:15AM
没有评论:
发表评论