Apllying code to every excel sheet

szymon94

New Member
Joined
Nov 14, 2022
Messages
20
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
Hello, I have a small problem. I have created code for myself but I cannot make a loop for all sheets ( every week it vary from 50 to 150 every week) I need to apply this code for all of the worksheets. What it does in every sheet I cave cell 2022 just one and in another column (13 in right) I have amounts so I select them and sum them in AG5. I would like to apply to all of the worksheets.


VBA Code:
Sub macro1()



Dim I As Range


Dim cell As Range

Set I = Range("O1:O50")


For Each cell In I.Cells

If cell.Value <> "2022.00" Then

cell.Offset(, 13).Resize(4).Select

Else

Range("AG5") = Application.Sum(Range(Selection.Address))

End If

Next


End Sub
 
That is done by the formatting in cell AG5, the VBA doesn't do any rounding.
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
do you know how to change this auto rounding, I have tried to put "number format" withing the code but it does not work at all
 
Upvote 0
Ok I have figured out thank you for your code and educated me for the future. Long way ahead of me
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,986
Members
449,060
Latest member
mtsheetz

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