Combine two bits of code

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,592
Office Version
  1. 365
Platform
  1. Windows
Hi all

Think I'm having a memory block..

I have this bit of code that will carry out a certain task on each of my worksheets

Code:
Sub updateSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Sheets
    With ws
        .Unprotect Password:=684556
        .Range("J203:J256").Validation.Delete
      
    End With
Next ws
End Sub

I actually want t the above to carry out the following in every worksheet but I can't seem to get them to work together..
Code:
Range("AB13").Select
    Selection.Cut
    Range("AB6").Select
    ActiveSheet.Paste
    Range("AB16").Select
    Selection.ClearContents
    Range("AC8").Select
    Selection.ClearContents
    Range("AD11").Select
    ActiveCell.FormulaR1C1 = "blank cell"
    Range("Z1").Select

thanks in advance
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Perhaps.
Code:
Sub updateSheets()
Dim ws As Worksheet
    For Each ws In ActiveWorkbook.Sheets
        With ws
            .Unprotect Password:=684556
            .Range("J203:J256").Validation.Delete
            .Range("AB13").Cut .Range("AB6")

            .Range("AB16").ClearContents
            .Range("AC8").ClearContents
            .Range("AD11").Value = "blank cell"
            Application.Goto .Range("Z1")
        End With
    Next ws
End Sub
 
Upvote 0
Code:
Sub updateSheets()
Dim ws As Worksheet


Application.ScreenUpdating = False


For Each ws In ActiveWorkbook.Sheets
    With ws
        .Range("AB13").Cut .Range("AB6")
        .Range("AB16").ClearContents
        .Range("AC8").ClearContents
        .Range("AD11") = "blank cell"
    End With
Next ws


Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,203,487
Messages
6,055,713
Members
444,810
Latest member
ExcelMuch

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