strongman86
Board Regular
- Joined
- Feb 15, 2017
- Messages
- 115
- Office Version
- 2019
- Platform
- Windows
Lads,
I have issue with my manually entered data on excel spreadsheet misaligning when data is refreshed from MS query e.g row is added or removed by query. I have came across this:
https://www.techsupportforum.com/forums/f57/mis-aligned-data-on-data-refresh-565373.html
I have tried to follow instructions, but when I run VBA I get run-time error '9': Subscript out of range.
In my case:
1) Unique Identifier is in column B (alphanumeric)
2) Yes I have headers
3) Extracted data worksheet name: MdProductDataList
4) Updated data worksheet name: Data
5) Excel is version 2013
Code I'm using:
Debug points out this:
cnt = Worksheets("Data").Range("B20000").End(xlUp).Row
How can I fix this? Thanks.
I have issue with my manually entered data on excel spreadsheet misaligning when data is refreshed from MS query e.g row is added or removed by query. I have came across this:
https://www.techsupportforum.com/forums/f57/mis-aligned-data-on-data-refresh-565373.html
I have tried to follow instructions, but when I run VBA I get run-time error '9': Subscript out of range.
In my case:
1) Unique Identifier is in column B (alphanumeric)
2) Yes I have headers
3) Extracted data worksheet name: MdProductDataList
4) Updated data worksheet name: Data
5) Excel is version 2013
Code I'm using:
Code:
Sub test()
Dim cnt, rw As Integer
Dim val As Variant
cnt = Worksheets("Data").Range("B20000").End(xlUp).Row
On Error Resume Next
For rw = cnt To 2 Step -1
val = Empty
val = Application.WorksheetFunction.VLookup(Worksheets("Data").Range("B" & rw).Value, Worksheets("MdProductDataList").Range("B:B"), 1, False)
If val = Empty Then
Worksheets("Data").Rows(rw).Delete
End If
nxt:
Next rw
End Sub
Debug points out this:
cnt = Worksheets("Data").Range("B20000").End(xlUp).Row
How can I fix this? Thanks.
Last edited by a moderator: