'Error 400 at a particular line of code in vba? [duplicate]
I have this code:
'Declare variables
Dim wb As Workbook
Dim rv As Range 'rv = row value
Dim wsn As String 'wsn = worksheet name
Dim ws As Worksheet
Dim rws As Worksheet 'record sheet worksheet
Dim ri As Long 'row index used for rv
'Set record workbook and worksheet
Set wb = ActiveWorkbook
Set rws = wb.Worksheets("Record sheet")
'refer to concatenate column
Dim lastr As Long
Dim r As Range
lastr = rws.Cells(Rows.Count, 1).End(xlUp).row
Set r = rws.Range(Cells(2, 7), Cells(lastr, 7))
But when it reaches this code:
Set r = rws.Range(Cells(2, 7), Cells(lastr, 7))
I get a 400 error. I've spent ages trying to figure out whats causing it and i don't know what I'm doing wrong. I've tested my rws variable and it works by going to the correct worksheet when running a "rws.select" test.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
