Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Change cell value based on other cell value

Can anyone tell me how to change the value of a cell in say column "B" based
on the value in a cell in column "A" when the value in column "A" is
alphanumeric? I am already able to make this code work when the value in
column "A" is numeric only, but the code does not have any affect when the
value in "A" is alphanumeric.

Here is the code I am using:

Sub test()
For i = 1 To Cells(Rows.Count, "C").End(xlUp).Row

If Cells(i, "a").Value = "dfg260" Then

Cells(i, "d").Value = "48"

End If
Next i
End Sub

thanks
--
Me! cypher
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Change cell value based on other cell value

Your code works fine on my sheet. What is the cell format for the cells in
your code?

Mike F
"cypher" wrote in message
...
Can anyone tell me how to change the value of a cell in say column "B"
based
on the value in a cell in column "A" when the value in column "A" is
alphanumeric? I am already able to make this code work when the value in
column "A" is numeric only, but the code does not have any affect when the
value in "A" is alphanumeric.

Here is the code I am using:

Sub test()
For i = 1 To Cells(Rows.Count, "C").End(xlUp).Row

If Cells(i, "a").Value = "dfg260" Then

Cells(i, "d").Value = "48"

End If
Next i
End Sub

thanks
--
Me! cypher



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Change cell value based on other cell value

Thanks for your suggestion Mike. The format the data imports as is 'general'.
I have tried changing the data to text format - post import, but the code
still would not recognize the alphanumeric number.

A VB developer friend of mine said that the data being imported contained
trailing spaces (invisible to the user) that was causing the code not to
recognize the data.

PS - is there a way to include both right 'and' left parts of the string?
--
Me! cypher


"Mike Fogleman" wrote:

Your code works fine on my sheet. What is the cell format for the cells in
your code?

Mike F
"cypher" wrote in message
...
Can anyone tell me how to change the value of a cell in say column "B"
based
on the value in a cell in column "A" when the value in column "A" is
alphanumeric? I am already able to make this code work when the value in
column "A" is numeric only, but the code does not have any affect when the
value in "A" is alphanumeric.

Here is the code I am using:

Sub test()
For i = 1 To Cells(Rows.Count, "C").End(xlUp).Row

If Cells(i, "a").Value = "dfg260" Then

Cells(i, "d").Value = "48"

End If
Next i
End Sub

thanks
--
Me! cypher




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Change cell value based on other cell value

Try using the TRIM function on your data before you run the macro. That can
usually clean out all unwanted spaces from the import.

Mike F
"cypher" wrote in message
...
Thanks for your suggestion Mike. The format the data imports as is
'general'.
I have tried changing the data to text format - post import, but the code
still would not recognize the alphanumeric number.

A VB developer friend of mine said that the data being imported contained
trailing spaces (invisible to the user) that was causing the code not to
recognize the data.

PS - is there a way to include both right 'and' left parts of the string?
--
Me! cypher


"Mike Fogleman" wrote:

Your code works fine on my sheet. What is the cell format for the cells
in
your code?

Mike F
"cypher" wrote in message
...
Can anyone tell me how to change the value of a cell in say column "B"
based
on the value in a cell in column "A" when the value in column "A" is
alphanumeric? I am already able to make this code work when the value
in
column "A" is numeric only, but the code does not have any affect when
the
value in "A" is alphanumeric.

Here is the code I am using:

Sub test()
For i = 1 To Cells(Rows.Count, "C").End(xlUp).Row

If Cells(i, "a").Value = "dfg260" Then

Cells(i, "d").Value = "48"

End If
Next i
End Sub

thanks
--
Me! cypher






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
Change background color of cell based on vlookup in cell Antney Excel Discussion (Misc queries) 1 October 19th 09 10:55 PM
Automatically change cell colors based on date in cell Greg Excel Discussion (Misc queries) 2 January 27th 09 05:55 PM
Change Text Color in one cell based upon entry in referenced cell Tee Excel Discussion (Misc queries) 3 September 12th 08 10:07 PM
change current cell colour based on the value of adjacent cell on other worksheet Rits Excel Programming 2 November 23rd 06 11:57 AM
How do I change cell color based upon data range within the cell? Chris Sanders Excel Worksheet Functions 1 March 6th 06 08:59 PM


All times are GMT +1. The time now is 07:19 PM.

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"