PC Review


Reply
Thread Tools Rate Thread

Change cell value based on other cell value

 
 
=?Utf-8?B?Y3lwaGVy?=
Guest
Posts: n/a
 
      24th Jan 2007
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 With Quote
 
 
 
 
Mike Fogleman
Guest
Posts: n/a
 
      24th Jan 2007
Your code works fine on my sheet. What is the cell format for the cells in
your code?

Mike F
"cypher" <(E-Mail Removed)> wrote in message
news:78198D92-842A-487A-8BFD-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?Y3lwaGVy?=
Guest
Posts: n/a
 
      26th Jan 2007
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" <(E-Mail Removed)> wrote in message
> news:78198D92-842A-487A-8BFD-(E-Mail Removed)...
> > 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 With Quote
 
Mike Fogleman
Guest
Posts: n/a
 
      26th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:FCFB355A-B4B1-4A7D-8A0A-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:78198D92-842A-487A-8BFD-(E-Mail Removed)...
>> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically change cell colors based on date in cell Greg Microsoft Excel Misc 1 27th Jan 2009 05:53 PM
Change 3rd cell colour based on cell 1 >= cell2 in range wombarrapete Microsoft Excel Discussion 8 21st Dec 2008 09:41 PM
Change Text Color in one cell based upon entry in referenced cell Tee Microsoft Excel Misc 3 12th Sep 2008 10:07 PM
change current cell colour based on the value of adjacent cell on other worksheet Rits Microsoft Excel Programming 2 23rd Nov 2006 11:57 AM
Please help! Macro to change cell contents based on cell to the left Jennifer Microsoft Excel Programming 7 4th Mar 2004 01:06 AM


Features
 

Advertising
 

Newsgroups
 


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