Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Incrementing a variable by 1

Apologies for the simple question, but I can't find the answer by
searching the net.

In PHP you can increment a variable by 1 thus:

$var++;

In some forms of BASIC it's:

var +=1

How do you incremenet a variable by 1 in VBA other than:

iVar = iVar + 1

Is there simpler way?

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Incrementing a variable by 1

Hi Sskulkrinbait,

The normal method would be that shown by you:

iVar = iVar + 1



---
Regards,
Norman

wrote in message
oups.com...
Apologies for the simple question, but I can't find the answer by
searching the net.

In PHP you can increment a variable by 1 thus:

$var++;

In some forms of BASIC it's:

var +=1

How do you incremenet a variable by 1 in VBA other than:

iVar = iVar + 1

Is there simpler way?

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Incrementing a variable by 1

iVar = iVar + 1 doesn't seem particularly onerous to me but another way is a
For - Next loop where the variable is increased by 1 when the next is
executed.

" wrote:

Apologies for the simple question, but I can't find the answer by
searching the net.

In PHP you can increment a variable by 1 thus:

$var++;

In some forms of BASIC it's:

var +=1

How do you incremenet a variable by 1 in VBA other than:

iVar = iVar + 1

Is there simpler way?

Thanks.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Incrementing a variable by 1

On Apr 27, 10:10 am, Mike H wrote:
iVar = iVar + 1 doesn't seem particularly onerous to me but another way is a
For - Next loop where the variable is increased by 1 when the next is
executed.



" wrote:
Apologies for the simple question, but I can't find the answer by
searching the net.


In PHP you can increment a variable by 1 thus:


$var++;


In some forms of BASIC it's:


var +=1


How do you incremenet a variable by 1 in VBA other than:


iVar = iVar + 1


Is there simpler way?


Thanks.- Hide quoted text -


- Show quoted text -


Thanks, I was wondering as some of my variable names are quite long so
if you could do it using var ++ or something it would save me a second
or two each time, I must be getting lazy.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Incrementing a variable by 1

Hi Sskulkrinbait,

'-----------------
Thanks, I was wondering as some of my variable names are quite long so
if you could do it using var ++ or something it would save me a second
or two each time, I must be getting lazy.
'-----------------

You could autocomplete the long variable name
using Ctrl_Shift ...



---
Regards,
Norman




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Incrementing a variable by 1

I was wondering as some of my variable names are quite long so

Hi. This is in my Library of routines. I shortened the name to "Inc" to
represent the "Increment" function.

Function Inc(ByRef n)
'// Increment by +1
n = n + 1
End Function

Sub Test()
Dim ALongVariableName
ALongVariableName = 6
Inc ALongVariableName
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2007


wrote in message
ups.com...
On Apr 27, 10:10 am, Mike H wrote:
iVar = iVar + 1 doesn't seem particularly onerous to me but another way
is a
For - Next loop where the variable is increased by 1 when the next is
executed.



" wrote:
Apologies for the simple question, but I can't find the answer by
searching the net.


In PHP you can increment a variable by 1 thus:


$var++;


In some forms of BASIC it's:


var +=1


How do you incremenet a variable by 1 in VBA other than:


iVar = iVar + 1


Is there simpler way?


Thanks.- Hide quoted text -


- Show quoted text -


Thanks, I was wondering as some of my variable names are quite long so
if you could do it using var ++ or something it would save me a second
or two each time, I must be getting lazy.



Reply
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
incrementing luuthur Excel Discussion (Misc queries) 4 May 23rd 07 05:07 AM
Variable Incrementing John Excel Discussion (Misc queries) 3 May 12th 06 10:16 PM
Next not incrementing davegb Excel Programming 11 March 19th 05 01:25 PM
Incrementing Variable shortcut crazybass2 Excel Programming 2 March 18th 05 03:31 PM
Increment variable not incrementing? [email protected] Excel Programming 3 November 19th 04 12:10 AM


All times are GMT +1. The time now is 10:16 AM.

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

About Us

"It's about Microsoft Excel"