Can't loop through worksheets

VBAWannabee2

New Member
Joined
Feb 23, 2022
Messages
28
Office Version
  1. 2010
Platform
  1. Windows
Hi All!

I have this code but I can't work it out to loop thru worksheets.
What it does is per sheet in my workbook, it copies the values on Column B to Column C (Only the visible cells because the data on all sheets was subtotaled)
Hope my explanation is clear enough. Please see screenshot also. Thanks for any assistance!

VBA Code:
Dim ws As Worksheet
Dim rng As Range

For Each ws In ActiveWorkbook.Worksheets

If ws.Visible = True Then

    For Each rng In Range(Cells.Find(What:="Total"), Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlVisible).Areas
      rng.Offset(, 1).Value = rng.Value
    Next rng
    
End If
    
Next ws
 

Attachments

  • Capture.JPG
    Capture.JPG
    62.1 KB · Views: 11
Glad we could help & thanks for the feedback.
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,215,073
Messages
6,122,977
Members
449,095
Latest member
Mr Hughes

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