How to add same text to all sheets in excel in a macro

almst791

Board Regular
Joined
Jun 29, 2016
Messages
82
Hey guys, I have some text Id like to add to the same cells in all my sheets in my report. Sheet names will change constantly is there any macros around this. I want to add text in these cells in excel. D68:D83.

Non-Reimbursable
Airfare/Baggage Fees
Fuel/Taxi/Other Transport
Lunch-Employee only
Parking/Tolls
Mileage Reimburse
Dinner-Employee only
Miscellaneous
Breakfast-Employee only
Rental Car
Lodging
Business Meals w/MCK Staff
Entertainment Events
Hotel (to be itemized)
Meal Exception – Employee Only
Business Meals w/Non MCK Staff
Phone/Internet-Airline/Airport
Gifts-Empl (to be itemized)
Phone/Internet-Lodging
Meeting Room Rent/Audio/Visual
Dues/Memberships/Subscriptions
Registration/Seminars/Training
TradeShow Exp – Mtg Dept Only
Gifts-Customers
Late Fees Non-Reimbursable

<colgroup><col></colgroup><tbody>
</tbody>
Non-Reimbursable
Airfare/Baggage Fees
Fuel/Taxi/Other Transport
Lunch-Employee only
Parking/Tolls
Mileage Reimburse
Dinner-Employee only
Miscellaneous
Breakfast-Employee only
Rental Car
Lodging
Business Meals w/MCK Staff
Entertainment Events
Hotel (to be itemized)
Meal Exception – Employee Only
Business Meals w/Non MCK Staff
Phone/Internet-Airline/Airport
Gifts-Empl (to be itemized)
Phone/Internet-Lodging
Meeting Room Rent/Audio/Visual
Dues/Memberships/Subscriptions
Registration/Seminars/Training
TradeShow Exp – Mtg Dept Only
Gifts-Customers
Late Fees Non-Reimbursable

<colgroup><col></colgroup><tbody>
</tbody>
 
Thank you man I have a lot of studying to do in VBA, this works perfect!

I also have a code that lists out a table of contents for my worksheet... Is there anyway I can combine the if statement to exclude the sheets above into this code. I've been trying but I am stumped with the IF in VBA.

Sub CreateLinksToAllSheets()


Dim sh As Worksheet
Dim cell As Range
For Each sh In ActiveWorkbook.Worksheets
If ActiveSheet.Name <> sh.Name Then
ActiveCell.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'" & sh.Name & "'" & "!A1", TextToDisplay:=sh.Name
ActiveCell.Offset(1, 0).Select
End If
Next sh
End Sub
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Just replace this line here:
Code:
[COLOR=#333333]If ActiveSheet.Name <> sh.Name Then
[/COLOR]
with the other IF line I showed you (once you adjust the object name from "ws" to "sh" to reflect how you are looping through the sheet, i.e.
Code:
[COLOR=#333333]If (sh.Name <> "Data") And (sh.Name <> "Cost Center") And (sh.Name <> "Cost Center Macro") Then[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,131
Messages
6,123,223
Members
449,091
Latest member
jeremy_bp001

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