check if there is 13 columns if not add one

Ynss

New Member
Joined
Feb 24, 2022
Messages
6
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
clients sent me a sheet that have a table from Week 1 to week 13 (13 column) some clients doesnt, for exemple just for 12, 11 weeks
i want a macro to check if there is 13 column if not add new column in specific place
any idea ?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Bit of a guess without seeing your code or what else might be on the worksheet but perhaps this might head you in the right direction?

VBA Code:
If ActiveSheet.UsedRange.Columns.Count <> 13 Then
  'Add the column(s) in your specific place
End If
 
Upvote 0
Thank you work great,
for the emplacement where i will add the column, it's dynamic, for example, if one client sends me a table with 12 weeks the headers will be, 1,2,3....12 in this case the new column will be added in the last , but another client send me a table like 1,2,4....13 so the new column should be added in the third place
any idea how to make this solution, and thank you
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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