This looks really good.
I totally agree; I am very new to all of this, as well as being old(!) and it explains things very clearly indeed.
Congratulatiuons to Jonmo1
This looks really good.
Heeey, dont worry, 84 isn't that old
LR = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:A" & LR)
LR = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count – 1
LC = Cells(1, Columns.Count).End(xlToLeft).Column
LC = ActiveSheet.UsedRange.Column + ActiveSheet.UsedRange.Columns.Count - 1
Application.Calculation = xlCalculationManual
‘Put your code here
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = False
‘Put your code here
Application.EnableEvents = True
Application.ScreenUpdating = False
‘Put your code here
Application.ScreenUpdating = True
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
End With
Application.Calculate
Sheets("Sheet1").Calculate
Sheets("Sheet1").Range("A1:A10").Calculate
Sheets("Sheet2").Select
Range("A1:A10").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1:A10").Select
Selection.PasteSpecial xlPasteValues
Sheets("Sheet2").Range("A1:A10").Copy
Sheets("Sheet1").Range("A1:A10").PasteSpecial xlPasteValues
For Each ws in Sheets
'The rest of your code goes here
Next ws
Sheets("Sheet1").Range("A1:E10").Interior.ColorIndex = 3
For Each ws In Sheets
ws.Range("A1:E10").Interior.ColorIndex = 3
Next ws
For Each ws In Sheets
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
Next ws
MySheets = Array("ThisOne", "ThisOneToo") 'Sheets you want the macro to run on go here.
For Each ws In Sheets
X = Application.Match(ws.Name, MySheets, 0)
If Not IsError(X) Then
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
End If
Next ws
For Each ws In Sheets
Select Case ws.Name
Case "ThisOne", "ThisOneToo" 'Sheets you want the macro to run on go here.
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
Case Else
'Do Nothing
End Select
Next ws
MySheets = Array("NotThisOne", "NorThisOne") 'Sheets you do not want the macro to run on go here.
For Each ws In Sheets
X = Application.Match(ws.Name, MySheets, 0)
If IsError(X) Then
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
End If
Next ws
For Each ws In Sheets
Select Case ws.Name
Case "NotThisOne", "NorThisOne" 'Sheets you do not want the macro to run on go here.
'Do Nothing
Case Else
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
End Select
Next ws
Sheets("Sheet1").Unprotect "PasswordGoesHere"
‘The rest of your code here
Sheets("Sheet1").Protect "PasswordGoesHere"
UserInterFaceOnly = True
Sheets("Sheet1").Protect Password:="PasswordHere", UserInterFaceOnly:=True
Private Sub Workbook_Open()
For Each ws In Sheets
ws.Protect Password:="PasswordHere", UserInterFaceOnly:=True
Next ws
End Sub
ActiveSheet.Name = ActiveSheet.Range("A1").Value
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0,0) <> "A1" Then Exit Sub
On Error Resume Next
Me.Name = Me.Range("A1").Value
On Error GoTo 0
If Me.Name <> Me.Range("A1").Value Then
MsgBox "An error occurred trying to rename the sheet to " & Me.Range("A1").Value _
& Chr(10) & "Either it already exists, has too many characters or has invalid characters"
End If
End Sub
Me.Name = Format(Me.Range("A1").Value, "mm-dd-yyyy")
Application.DisplayAlerts = False
With Sheets("Sheet1")
LR = .Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To LR
Sheets.Add After:=Sheets(Sheets.Count)
On Error Resume Next
ActiveSheet.Name = .Range("A" & i).Value
On Error GoTo 0
If ActiveSheet.Name <> .Range("A" & i).Value Then
ActiveSheet.Delete
MsgBox "An error occurred creating the sheet " & .Range("A" & i).Value _
& Chr(10) & "The sheet was not created"
End If
Next i
End With
Application.DisplayAlerts = True
as opposed to this:=SUMPRODUCT(--(A1:A100="SomeWord"),--(B1:B100="AnotherWord"),C1:C100)
might be worth some sort of debate. I guess it ultimately depends on the target audience and what people at MrExcel consider to be best practice. I always used to use the former, but then Nate convinced me otherwise.... So which construction does Mr Excel advocate, the one that's more efficient or the one that's easier to understand, and which one is the most appropriate here? Not for me to say.... but it is a valid question!=SUMPRODUCT(-(A1:A100="SomeWord"),-(B1:B100="AnotherWord"),C1:C100)
For Each ws In Sheets
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
Next ws
Dim ws as Worksheet
For Each ws In Worksheets
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
Next ws
Sub foo()
Dim ws As Object
For Each ws In Sheets
If TypeOf ws Is Worksheet Then
'or alternatively:
'If TypeName(ws) = "Worksheet" Then
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End If
Next ws
End Sub
Dim ws As Object
For Each ws In Sheets
If TypeOf ws Is Worksheet Then
'or alternatively:
'If TypeName(ws) = "Worksheet" Then
With ws
.Range("A1:E10").Interior.ColorIndex = 3
.Range("G1:K10").Interior.ColorIndex = 6
End With
End If
Next ws