View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Need help with setting variables

Not sure what you are trying to achieve, but
- It is a good idea, in the VBE, to set ToolsOptionsEditorcheck Require
Variable Declaration
This will put "Option Explicit" at the top of all modules, forcing you to
declare them. Check the Help.
And add Option Explicit manually to your current module.

You mean something like

Dim A as string,B as string,C as string
A = "James"
B = "Ron"
C = "Tony"

Range("M33").Select
If Range("AB22").Value = "N" Then
ActiveCell = A
Else
ActiveCell = "Alternate"
End If

Like this though, A, B & C are not very variable, as all the values are
hard-coded, so you do not really gain anything by assigning the variables.

Depends what the source of your values is.

NickHK

"erikkeith via OfficeKB.com" <u13156@uwe wrote in message
news:68a0394555271@uwe...
I want to set variables so I can use them in the following way:

A = James
B = Ron
C = Tony

Range("M33").Select
If Range("AB22").Value = "N" Then
ActiveCell = "A"
Else: ActiveCell = "Alternate"
End If

What syntax to I use to make this run in VBA?

--
Message posted via http://www.officekb.com