Privateer59
New Member
- Joined
- Jun 3, 2015
- Messages
- 2
I am trying to assign a range to a variable. The row number (TRN) is 17 and the column number (TCN) is 10. I would like to assign the variable current sheet range (CSR), dimmed as a range, to this:
Row 18 Column 5 through Row 18 Column 10 which equals "E18:J18"
Set CSR = xlSheet.Range(Cells(" & (TRN + 1) & ", " & (TCN - 5) & "), Cells(" & (TRN + 1) & ", " & TCN & "))
The error is "1004 Method 'Cells' of object '_Global' failed", whatever that means.
What I was hoping for is this: Set CSR = xlSheet.Range(Cells(18, 5), Cells(18, 10))
I have to do this dynamically as "J17" is the control-end cell (last cell) in the sheet and the next time the data is exported from Access, the last row will be different. I would like the range assigned to the variable CSR so I can assign a formula and do some formatting. Been messing with this for a while and I am really frustrated. Just want to sum five columns of numbers without knowing where the bottom is each time. Any help would be greatly appreciated.
Privateer59
p.s. if you are interested:
TRN = xlSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
TCN = xlSheet.Cells.SpecialCells(xlCellTypeLastCell).Column
Row 18 Column 5 through Row 18 Column 10 which equals "E18:J18"
Set CSR = xlSheet.Range(Cells(" & (TRN + 1) & ", " & (TCN - 5) & "), Cells(" & (TRN + 1) & ", " & TCN & "))
The error is "1004 Method 'Cells' of object '_Global' failed", whatever that means.
What I was hoping for is this: Set CSR = xlSheet.Range(Cells(18, 5), Cells(18, 10))
I have to do this dynamically as "J17" is the control-end cell (last cell) in the sheet and the next time the data is exported from Access, the last row will be different. I would like the range assigned to the variable CSR so I can assign a formula and do some formatting. Been messing with this for a while and I am really frustrated. Just want to sum five columns of numbers without knowing where the bottom is each time. Any help would be greatly appreciated.
Privateer59
p.s. if you are interested:
TRN = xlSheet.Cells.SpecialCells(xlCellTypeLastCell).Row
TCN = xlSheet.Cells.SpecialCells(xlCellTypeLastCell).Column