Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Can VBA If...Then execute a block of code instead of a single line
Hello All,
Is there some way in Excel 2007 VBA macro code to have a block of code perform if a condition is true and have the code block skipped if the condition is false? So far I have only been able to get an If...Then condition to work with a single line of code following the Then statement. Do I use GoSub...Return? See the following code: Range("I6").Select If ActiveCell.FormulaR1C1 = "HCP Added" Then _ ActiveSheet.Unprotect Range("I6").Select Selection.ClearContents ActiveSheet.Protect DrawingObjects:=True, Contents:=True, _ Scenarios:=True, AllowInsertingHyperlinks:=True End If Calculate If Sheets("Data Entry").Visible = True Then Sheets("Data Entry").Select ActiveWindow.SelectedSheets.Visible = False End If If Sheets("Main Menu").Visible = True Then Sheets("Main Menu").Select Range("F4:H4").Select End If End Sub Can you assist and tell me what I am doing wrong? -- Brian |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Single line of code with line separator | Excel Programming | |||
how do you execute single line of code? | Excel Discussion (Misc queries) | |||
VBA Array Population with a Single Line of Code | Excel Programming | |||
Way to change a single line of vb code in several hundred excel files? | Excel Programming | |||
Way to change a single line of vb code in several hundred excel files? | Excel Programming |