LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Single line of code with line separator KarenF Excel Programming 4 August 19th 08 01:43 AM
how do you execute single line of code? honestlylion Excel Discussion (Misc queries) 2 February 24th 06 03:35 PM
VBA Array Population with a Single Line of Code James B Excel Programming 7 February 6th 04 09:37 AM
Way to change a single line of vb code in several hundred excel files? bball887 Excel Programming 2 December 16th 03 03:24 PM
Way to change a single line of vb code in several hundred excel files? Alex[_13_] Excel Programming 0 December 15th 03 06:13 PM


All times are GMT +1. The time now is 02:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"