VBA column check

Mr2017

Well-known Member
Joined
Nov 28, 2016
Messages
644
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I've got some code which checked the if a file had 8 columns in it, before it allowed you to import data from the file into Excel.

However, the data in that file started on row 1.

I've got a file where the data starts in row 8, and I wanted to amend the code below, so it checks if the file has 28 columns starting from cell A8.

Does anyone know how to do this? TIA

If ActiveSheet.Cells.SpecialCells(xlLastCell).Column <> 28 Then
MsgBox "Check you've selected the right file"
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Ok, thanks Fluff. I'll test it tomorrow.

I'm re-writing / adapting code from a previous workbook that I'd worked on, so was planning to test it all once I'd finished it. But I'll test it in bits. Thanks
 
Upvote 0

Forum statistics

Threads
1,217,378
Messages
6,136,204
Members
450,000
Latest member
jgp19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top