Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variable Command for VBA in Excel

Good Morning Everyone,

I have a question for you VBA Experts out there. I'm trying to organize data
through color coding using the "For Each" loop, and I'm wondering if there is
a command that can define a variable?

For Example, a product number we have is D0000200, but there is another
product number that is D00002001. Both of these products are in the same
group, despite having different numbers.

I'm wondering if VBA can discriminate (or if there is a code that can act as
a variable, such as X in a simple math problem) the "D0000" portion of the
code and look expressly at the "200" or "2001" expression?

Any help is greatly appreciated!!!

~Fernando, IBT Employee

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 192
Default Variable Command for VBA in Excel

You can certainly write something that says

If ActiveCell = "*2001" then blah blah
else if Active Cell = "*200" then blah blah
end if

If you define the cell that you're looking at as CurrentProduct then you
could do something similar such as:

If CurrentProduct.Value like "*2001" then blah blah
else if CurrentProduct.Value like "*200" then blah blah
end if

The "*" is a wild card and accounts for anything.

Is this what you're looking for?

"IBT Employee" wrote:

Good Morning Everyone,

I have a question for you VBA Experts out there. I'm trying to organize data
through color coding using the "For Each" loop, and I'm wondering if there is
a command that can define a variable?

For Example, a product number we have is D0000200, but there is another
product number that is D00002001. Both of these products are in the same
group, despite having different numbers.

I'm wondering if VBA can discriminate (or if there is a code that can act as
a variable, such as X in a simple math problem) the "D0000" portion of the
code and look expressly at the "200" or "2001" expression?

Any help is greatly appreciated!!!

~Fernando, IBT Employee

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Variable Command for VBA in Excel

Yes thank you, both of these replies have clarified the situation greatly.

"StumpedAgain" wrote:

You can certainly write something that says

If ActiveCell = "*2001" then blah blah
else if Active Cell = "*200" then blah blah
end if

If you define the cell that you're looking at as CurrentProduct then you
could do something similar such as:

If CurrentProduct.Value like "*2001" then blah blah
else if CurrentProduct.Value like "*200" then blah blah
end if

The "*" is a wild card and accounts for anything.

Is this what you're looking for?

"IBT Employee" wrote:

Good Morning Everyone,

I have a question for you VBA Experts out there. I'm trying to organize data
through color coding using the "For Each" loop, and I'm wondering if there is
a command that can define a variable?

For Example, a product number we have is D0000200, but there is another
product number that is D00002001. Both of these products are in the same
group, despite having different numbers.

I'm wondering if VBA can discriminate (or if there is a code that can act as
a variable, such as X in a simple math problem) the "D0000" portion of the
code and look expressly at the "200" or "2001" expression?

Any help is greatly appreciated!!!

~Fernando, IBT Employee

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
Variable Or Command str83dgeboi Excel Worksheet Functions 7 November 13th 08 07:42 PM
Possible to pass a variable to Excel from command line/short cut? Jon[_25_] Excel Programming 3 April 16th 08 10:30 PM
SUM command using variable sheets IanC Excel Worksheet Functions 3 May 18th 07 11:56 PM
Syntax for Excel variable using a SQL Select/From/Where Command... Chip Pearson Excel Programming 0 September 8th 04 11:15 PM
variable 'open' command Walt[_2_] Excel Programming 3 July 27th 03 09:06 PM


All times are GMT +1. The time now is 07:09 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"