VBA Set the Format of Columns A and B to "General"

Dannottheman

Board Regular
Joined
Dec 24, 2020
Messages
55
Office Version
  1. 2007
Good morning,

I searched for this and could not find it. Does anyone know of a VBA to set the content/cells in both columns A and B to "general". I know I can do this manually, but I have several tasks that will run via a VBA and I prefer to add this to the existing VBA rather than to manually have to do it as I have a couple of hundred files to do.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
How about
VBA Code:
   Columns("A:B").NumberFormat = "General"
 
Upvote 0
Columns("A:B").NumberFormat = "General"

which can also be written this way...

[A:B].NumberFormat = "General"
 
Upvote 0
Solution
Thank you. Is there anything else I need to it for the VBA to work, or literally it's just inputting this in the VBA module: [A:B].NumberFormat = "General"
 
Upvote 0
Just add that line to your existing code.
 
Upvote 0
Sorry, this is my existing code. Where exactly can it be added:

Sub Test()

Application.ScreenUpdating = False

With ActiveSheet.Columns("A")

.ColumnWidth = 95

.WrapText = True

End With

Application.ScreenUpdating = True

End Sub
 
Upvote 0
Probably doesn't matter, but try putting it after the End With line
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,222,622
Messages
6,167,128
Members
452,098
Latest member
xel003

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