DonAndress
Active Member
- Joined
- Sep 25, 2011
- Messages
- 365
- Office Version
- 365
- 2021
- Platform
- Windows
Hello.
I have two lines of code.
Can anyone please help me understand why first one works and the second one does not?
All variables have values, both lines refer to the same Range (I checked in the Immediate window).
allCols = 58 = BF
The second line is throwing me "Run-time error '1004', Application-defined or object-defined error".
How to fix that to properly use Cells?
I have two lines of code.
Can anyone please help me understand why first one works and the second one does not?
VBA Code:
Workbooks(Wkb).Sheets(Sht).Range("C12:BF12").Value = Workbooks(Wkb).Sheets(ShtS).Range("C12:BF12").Offset(i, 0).Value
Code:
Workbooks(Wkb).Sheets(Sht).Range(Cells(12, 3), Cells(12, allCols)).Value = Workbooks(Wkb).Sheets(ShtS).Range(Cells(12 + i, 3), Cells(12 + i, allCols)).Value
All variables have values, both lines refer to the same Range (I checked in the Immediate window).
allCols = 58 = BF
The second line is throwing me "Run-time error '1004', Application-defined or object-defined error".
How to fix that to properly use Cells?