473,412 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

What does mean := in VBA ?

Hi.
Can anyone tell the purpose/meaning of ":=" which is used in VBA ? It sounds like a smiley, lol.

Example :

ActiveWorkbook.Sheets("Sheet1").Copy after:=ActiveWorkbook.Sheets ("Sheet1")

Thanks in advance....
Dec 13 '07 #1
1 14901
SammyB
807 Expert 512MB
In VBA, := allows you to specify named parameters. In your example, the Copy method has two optional parameters, Before and After, so you can also write your code as
ActiveWorkbook.Sheets("Sheet1").Copy (,ActiveWorkbook.Sheets ("Sheet1"))

So, using the := with named parameters allows you to see clearly which parameters were passed, plus you can specify them in any order. You can use this in your own code, see example below. In this silly example, NamedParametersTest(, , , , , , , , , , 22) and NamedParametersTest(k:=22) give the same result. HTH --Sam
Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2.     MsgBox NamedParametersTest(, , , , , , , , , , 22)
  3.     MsgBox NamedParametersTest(k:=22)
  4. End Sub
  5. Function NamedParametersTest(Optional a, Optional b, Optional c, _
  6.                         Optional d, Optional e, Optional f, Optional g, _
  7.                         Optional h, Optional i, Optional j, Optional k, _
  8.                         Optional l, Optional m, Optional n, Optional p)
  9.     If Not IsMissing(a) Then
  10.         NamedParametersTest = "a=" & a
  11.     ElseIf Not IsMissing(b) Then
  12.         NamedParametersTest = "b=" & b
  13.     ElseIf Not IsMissing(c) Then
  14.         NamedParametersTest = "c=" & c
  15.     ElseIf Not IsMissing(d) Then
  16.         NamedParametersTest = "d=" & d
  17.     ElseIf Not IsMissing(e) Then
  18.         NamedParametersTest = "e=" & e
  19.     ElseIf Not IsMissing(f) Then
  20.         NamedParametersTest = "f=" & f
  21.     ElseIf Not IsMissing(g) Then
  22.         NamedParametersTest = "g=" & g
  23.     ElseIf Not IsMissing(h) Then
  24.         NamedParametersTest = "h=" & h
  25.     ElseIf Not IsMissing(i) Then
  26.         NamedParametersTest = "i=" & i
  27.     ElseIf Not IsMissing(j) Then
  28.         NamedParametersTest = "j=" & j
  29.     ElseIf Not IsMissing(k) Then
  30.         NamedParametersTest = "k=" & k
  31.     ElseIf Not IsMissing(l) Then
  32.         NamedParametersTest = "l=" & l
  33.     ElseIf Not IsMissing(m) Then
  34.         NamedParametersTest = "m=" & m
  35.     ElseIf Not IsMissing(n) Then
  36.         NamedParametersTest = "n=" & n
  37.     ElseIf Not IsMissing(p) Then
  38.         NamedParametersTest = "p=" & p
  39.     End If
  40. End Function
  41.  
Dec 13 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
3
by: Jukka K. Korpela | last post by:
I have noticed that the meaning of visibility: collapse has been discussed on different forums, but with no consensus on what it really means. Besides, implementations differ. The specification...
86
by: Michael Kalina | last post by:
Because when I asked for comments on my site-design (Remember? My site, your opinion!) some of you told me never to change anything on font-sizes! What do you guys think of that:...
44
by: lester | last post by:
a pre-beginner's question: what is the pros and cons of .net, compared to ++ I am wondering what can I get if I continue to learn C# after I have learned C --> C++ --> C# ?? I think there...
2
by: Steve Richter | last post by:
What does the "." mean in the following sql script stmts? use GO if exists (select * from dbo.sysobjects where id = object_id(N'.') and OBJECTPROPERTY(id,N'IsUserTable') = 1) drop table ....
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
51
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
1
by: Frank Rizzo | last post by:
Some of the classes in the framework are marked as thread-safe in the documentation. In particular the docs say the following: "Any public static (*Shared* in Visual Basic) members of this type...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
9
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.