Glasgowsmile
Active Member
- Joined
- Apr 14, 2018
- Messages
- 280
- Office Version
- 365
- Platform
- Windows
Good Morning,
I'm using the following code below but ran into a minor issue. It's pulling data from Section2 on another spreadsheet, but sometimes that spreadsheet doesn't have Section2 and so it causes an error. How can I get the code to ignore the error or ignore this code if the spreadsheet doesn't have a Section2, so it can continue with the other lines of code without issues?
I'm using the following code below but ran into a minor issue. It's pulling data from Section2 on another spreadsheet, but sometimes that spreadsheet doesn't have Section2 and so it causes an error. How can I get the code to ignore the error or ignore this code if the spreadsheet doesn't have a Section2, so it can continue with the other lines of code without issues?
Code:
Cols = Application.CountA(wkbCrntWorkBook.Sheets("AAA Discount").Range("A2:A100")) + 1 Sheets("Section2").Range("B23:B100").Copy wkbCrntWorkBook.Sheets("AAA Discount").Cells(2, Cols)
wkbCrntWorkBook.Sheets("AAA Discount").Cells(1, Cols).CurrentRegion.EntireColumn.AutoFit