Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
colour cells using VBA | Excel Discussion (Misc queries) | |||
Changing all cells in one colour to a different colour | Excel Discussion (Misc queries) | |||
Cells changes colour if.... | Excel Worksheet Functions | |||
Will excel add cells using colour coding eg Add all red cells | Excel Discussion (Misc queries) | |||
Adding colour to a range of cells based on one of the cells v... | Excel Discussion (Misc queries) |