Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA help to test the activecell.value
I am new to VBA macro's and can not get the following test to work
Range("I4").Select If ActiveCell.Value = "W" Then GoTo WVEnumber If ActiveCell.Value = "G" Then GoTo BIGnumber If ActiveCell.Value = "F" Then GoTo BIFnumber The Macro branches to WVEnumber - no matter what is in the cell "I4" - can anyone help? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA help to test the activecell.value
Your code works for me. ???
Sub test() Range("I4").Select If ActiveCell.Value = "W" Then MsgBox "WVEnumber" If ActiveCell.Value = "G" Then MsgBox "BIGnumber" If ActiveCell.Value = "F" Then MsgBox "BIFnumber" End Sub "Marie" wrote: I am new to VBA macro's and can not get the following test to work Range("I4").Select If ActiveCell.Value = "W" Then GoTo WVEnumber If ActiveCell.Value = "G" Then GoTo BIGnumber If ActiveCell.Value = "F" Then GoTo BIFnumber The Macro branches to WVEnumber - no matter what is in the cell "I4" - can anyone help? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA help to test the activecell.value
Perhaps you are on the wrong sheet
Try With Worksheets("Sheet1").Range("I4") If .Value = "W" Then GoTo WVEnumber If .Value = "G" Then GoTo BIGnumber If .Value = "F" Then GoTo BIFnumber End With -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Marie" wrote in message ... I am new to VBA macro's and can not get the following test to work Range("I4").Select If ActiveCell.Value = "W" Then GoTo WVEnumber If ActiveCell.Value = "G" Then GoTo BIGnumber If ActiveCell.Value = "F" Then GoTo BIFnumber The Macro branches to WVEnumber - no matter what is in the cell "I4" - can anyone help? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA help to test the activecell.value
If EVEnumber, BIGnumber, & BIFnumber are range names then go to them by
selecting or activating that range: If ActiveCell.Value = "W" Then Range("WVEnumber").Select ' or activate Alan "Marie" wrote: I am new to VBA macro's and can not get the following test to work Range("I4").Select If ActiveCell.Value = "W" Then GoTo WVEnumber If ActiveCell.Value = "G" Then GoTo BIGnumber If ActiveCell.Value = "F" Then GoTo BIFnumber The Macro branches to WVEnumber - no matter what is in the cell "I4" - can anyone help? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA help to test the activecell.value
Yippee ! - at last
This works fine - thankyou for your help "Bob Phillips" wrote: Perhaps you are on the wrong sheet Try With Worksheets("Sheet1").Range("I4") If .Value = "W" Then GoTo WVEnumber If .Value = "G" Then GoTo BIGnumber If .Value = "F" Then GoTo BIFnumber End With -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Marie" wrote in message ... I am new to VBA macro's and can not get the following test to work Range("I4").Select If ActiveCell.Value = "W" Then GoTo WVEnumber If ActiveCell.Value = "G" Then GoTo BIGnumber If ActiveCell.Value = "F" Then GoTo BIFnumber The Macro branches to WVEnumber - no matter what is in the cell "I4" - can anyone help? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel VBA help to test the activecell.value
As you are new to VBA, you still have time to learn good practices and
unlearn bad ones. Try to avoid GoTo statements, and instead structure your code with conditional statements (e.g., the If statement) and/or by calling other procedures. GoTo in nearly universally avoided by professional programmers. -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) "Marie" wrote in message ... I am new to VBA macro's and can not get the following test to work Range("I4").Select If ActiveCell.Value = "W" Then GoTo WVEnumber If ActiveCell.Value = "G" Then GoTo BIGnumber If ActiveCell.Value = "F" Then GoTo BIFnumber The Macro branches to WVEnumber - no matter what is in the cell "I4" - can anyone help? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can you help test our Excel test? | Excel Discussion (Misc queries) | |||
If activecell.column = variable then activecell,offset (0,1) | Excel Discussion (Misc queries) | |||
How to Revert to ActiveCell.Formula = format from ActiveCell.FormulaR1C1 = format | Excel Programming | |||
Test if ActiveCell is within a certain named range | Excel Programming | |||
Excel VBA - use of ActiveCell.FormulaR1C1 | Excel Programming |