I need help with this code. I have an excel worksheet that I will import into an access table. The range to be imported will change with each sheet. I'm 90% of the way there, I just need help getting across the finish line. My problem is this: the code below is supposed to find the last row with text and define the range between the last row and the starting cell. Unfortunately this code automatically calculates and names a range that ends 26 rows from where it's supposed to. Any help would be appreciated.
I tried to upload the file, but because it's a .xlsm file, the forum won't let me upload it.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim lastRow As Long
Dim Range1 As Range
lastRow = Sheet1.Range("B77").End(xlUp).Row
'Let's assume your table begins at cell A3 and has two columns
Set Range1 = Sheet1.Range("B27").Resize(lastRow, 9)
Range1.Name = "WorkRequest"
Set Range1 = Nothing
End Sub
Last edited: