Enter values and format them on multiples worksheets all at once with VBA

alexxgalaxy

New Member
Joined
Sep 19, 2011
Messages
2
Hi, could anyone help me with below?



What needs changing in the following codes if I would like the following conditions met?
  1. the actions are done on every sheet except sheet("Master DB") as well as sheet("Summary").
  2. the InputBox pops up only ONCE and then the same value will be filled in specified range in every targeted sheet.
  3. the column width for column A is 18.
  4. the font of the character in the first four rows is Arial with a size of 14.
  5. the font in point 4 is bold.
Code:
Option Explicit
Code:
[FONT=Arial]Sub AddInfo()[/FONT]
[FONT=Arial] Dim n As Long[/FONT]
[FONT=Arial] Dim MySh As String[/FONT]
 
[FONT=Arial] MySh = "Master DB"[/FONT]
 
[FONT=Arial] For n = 3 To Sheets.Count[/FONT]
[FONT=Arial]     If Sheets(n).Name <> MySh Then[/FONT]
[FONT=Arial]         With Sheets(n)[/FONT]
[FONT=Arial]             .Range("A1") = "ABC"[/FONT]
[FONT=Arial]             .Range("A2") = "DEF"[/FONT]
[FONT=Arial]             .Range("A3") = Sheets(n).Name[/FONT]
[FONT=Arial]             .Range("A4") = InputBox("Please enter the date.")[/FONT]
[FONT=Arial]             .Range("A4").NumberFormatLocal = "[$-C04]d mmmm, yyyy;@"[/FONT]
[FONT=Arial]             .Range("B1:B4") = ":"[/FONT]
[FONT=Arial]             .Columns("A:A").ColumnWidth = 18[/FONT]
[FONT=Arial]             .Rows("1:4").Font.Name = "Arial"[/FONT]
[FONT=Arial]             .Rows("1:4").Font.Size = 14[/FONT]
[FONT=Arial]             .Rows("1:4").Font.Bold = True[/FONT]
[FONT=Arial]         End With[/FONT]
[FONT=Arial]     End If[/FONT]
[FONT=Arial] Next[/FONT]
 
[FONT=Arial]End Sub[/FONT]
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,224,560
Messages
6,179,519
Members
452,921
Latest member
BBQKING

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