Vba :

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

What does it mean when there is a semi colon after a text

E.g
Do nothing:
Range[a1]:

thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
mahmed1,

This is a semicolon ;
The two-dots is a colon :

A colon in VBA tells the compiler to treat anything after the colon as a new line of code.

For example:
Code:
For i = 1 To 10
    MsgBox i
Next i


could instead be written as:
Code:
For i = 1 To 10: MsgBox i: Next i



This is not to be confused with colon equals :=
That indicates the assignment of a value or expression to a method's argument.
Using the above example, the msgbox Prompt argument is the variable i. I omitted the argument because its not necessary to explicitly state it. For the purposes of showing the difference between := and : though, the above example could be written as:
Code:
For i = 1 To 10: MsgBox Prompt:=i: Next i
 
Upvote 0
mahmed1,

This is a semicolon ;
The two-dots is a colon :

A colon in VBA tells the compiler to treat anything after the colon as a new line of code.

For example:
Code:
For i = 1 To 10
    MsgBox i
Next i


could instead be written as:
Code:
For i = 1 To 10: MsgBox i: Next i



This is not to be confused with colon equals :=
That indicates the assignment of a value or expression to a method's argument.
Using the above example, the msgbox Prompt argument is the variable i. I omitted the argument because its not necessary to explicitly state it. For the purposes of showing the difference between := and : though, the above example could be written as:
Code:
For i = 1 To 10: MsgBox Prompt:=i: Next i

Thank you
 
Upvote 0
Hello mahmed1,

What you have shown is a colon :)) not a semi-colon (;).

A colon is used in VBA to tell the interpreter it has reached the end of a statement on that line. Multiple statements can appear on a single line when separated by colons.
Code:
N = 2: X = N ^ 2: MsgBox "N Squared = " & X
If a statement starts in column 1 of the VB editor and is followed by a colon with no other statements on that line, it is considered to a be a line label. You can transfer control to a line label with a Goto or GoSub statement.
Code:
If N <= 0 Then 
   GoTo EndMarco
End If

...

EndMacro:
    Application.Calculation = xlCalculationAutomatic
    Application.EnableEvents = True
    Application.DisplayAlerts = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,216,728
Messages
6,132,355
Members
449,720
Latest member
NJOO7

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top