ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Colour Cells onSheet (https://www.excelbanter.com/excel-programming/379813-re-colour-cells-onsheet.html)

Zone

Colour Cells onSheet
 
Hazel, I don't understand the need for 3 if statements. Why can't you
just say
If ws.Name<"Sheet 1" and ws.Name<"Sheet 2" and ws.Name <"Sheet 3"
Then
? James
Hazel wrote:
Hi All

A few days ago I used this forum and sorted out my problems with the following


Sub Macro2()
For Each ws In Worksheets
If ws.Name < "Sheet 1" Then
If ws.Name < "Sheet 2" Then
If ws.Name < "Sheet 3" Then
With ws

.Range("F3:F52").Copy .Range("H3")
.Columns("H:H").Insert Shift:=xlToRight
.Range("F3:F52").ClearContents

'what about this line for each sheet
Sheets("Sheet 1").Range("A2:C26").ClearContents
Application.Goto Sheets("Sheet 2").Range("F3")


End With
End If
End If
End If
Next ws
End Sub

To really finish the macro off and keep my boss happy, in Column H after
running the macro are numbers on the relevant rows and cells (most of the
time their are blank rows and cells between the relevant numbers) what they
would really like to happen is the numbers being deleted and the cells
changing colour so they can see at a glance who is doing the business on that
day.
--
Many thanks

hazel



Zone

Colour Cells onSheet
 
Hazel, thank you. The beauty of only one If statement is that you only
need one End If statement as well, and this will make your code much
easier to maintain. You seem to be making progress on your original
question! Best regards, James
Hazel wrote:
Hi

Cause I ain't clever I just do it - I started by just leaving out 1 sheet,
then needed to leave out another etc - so just carried on that way -- now you
have shown me the light -- I have learnt something and I thank you -- and its
in the brain box for future reference.
--
Many thanks

hazel


"Zone" wrote:

Hazel, I don't understand the need for 3 if statements. Why can't you
just say
If ws.Name<"Sheet 1" and ws.Name<"Sheet 2" and ws.Name <"Sheet 3"
Then
? James
Hazel wrote:
Hi All

A few days ago I used this forum and sorted out my problems with the following


Sub Macro2()
For Each ws In Worksheets
If ws.Name < "Sheet 1" Then
If ws.Name < "Sheet 2" Then
If ws.Name < "Sheet 3" Then
With ws

.Range("F3:F52").Copy .Range("H3")
.Columns("H:H").Insert Shift:=xlToRight
.Range("F3:F52").ClearContents

'what about this line for each sheet
Sheets("Sheet 1").Range("A2:C26").ClearContents
Application.Goto Sheets("Sheet 2").Range("F3")


End With
End If
End If
End If
Next ws
End Sub

To really finish the macro off and keep my boss happy, in Column H after
running the macro are numbers on the relevant rows and cells (most of the
time their are blank rows and cells between the relevant numbers) what they
would really like to happen is the numbers being deleted and the cells
changing colour so they can see at a glance who is doing the business on that
day.
--
Many thanks

hazel






All times are GMT +1. The time now is 11:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com