ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel VBA help to test the activecell.value (https://www.excelbanter.com/excel-programming/413040-excel-vba-help-test-activecell-value.html)

Marie

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?


Mike

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?


Bob Phillips

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?




Alan

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?


Marie

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?





Chip Pearson

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?




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com