Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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
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
Can you help test our Excel test? Jeff[_14_] Excel Discussion (Misc queries) 1 December 7th 09 05:11 PM
If activecell.column = variable then activecell,offset (0,1) Battykoda via OfficeKB.com Excel Discussion (Misc queries) 1 October 2nd 07 08:05 PM
How to Revert to ActiveCell.Formula = format from ActiveCell.FormulaR1C1 = format Karthik Bhat - Bangalore[_2_] Excel Programming 1 May 9th 07 02:37 PM
Test if ActiveCell is within a certain named range Steven Excel Programming 2 March 8th 06 05:18 PM
Excel VBA - use of ActiveCell.FormulaR1C1 pgi Excel Programming 1 June 1st 04 08:12 AM


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

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

About Us

"It's about Microsoft Excel"