ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   if then question (https://www.excelbanter.com/excel-worksheet-functions/146660-if-then-question.html)

Roger

if then question
 
I have two columns one(A) with continuous data from top to bottom, the other
(B) with simular data only dispersed randomly from top to bottom. What I
would like to do is replace the data in column A with the contents of column
B, only when there is data in the cell in column B, if there is no data I
want the data in column A left the way it is.
thanks in advance for the help.
Roger

Don Guillett

if then question
 
One way.
Sub replaceifdata()
lr = Cells(Rows.Count, "b").End(xlUp).Row
For Each c In Range("b1:b" & lr)
If Len(Trim(c)) 0 Then c.Offset(, -1) = c
Next
End Sub

--
Don Guillett
SalesAid Software

"Roger" wrote in message
...
I have two columns one(A) with continuous data from top to bottom, the
other
(B) with simular data only dispersed randomly from top to bottom. What I
would like to do is replace the data in column A with the contents of
column
B, only when there is data in the cell in column B, if there is no data I
want the data in column A left the way it is.
thanks in advance for the help.
Roger



Rick Rothstein \(MVP - VB\)

if then question
 
I have two columns one(A) with continuous data from top to bottom, the
other
(B) with simular data only dispersed randomly from top to bottom. What I
would like to do is replace the data in column A with the contents of
column
B, only when there is data in the cell in column B, if there is no data I
want the data in column A left the way it is.
thanks in advance for the help.


You can do that directly... Copy the range you want from column B, click the
matching start cell in column A, then select Paste Special from the Edit
menu item... on the Paste Special dialog box, select Values from the Paste
section, None from the Operation section and check mark the Skip Blanks
box... click OK and you are done.

Rick


Don Guillett

if then question
 
Unless a blank in col B is NOT really a blank

--
Don Guillett
SalesAid Software

"Rick Rothstein (MVP - VB)" wrote in
message ...
I have two columns one(A) with continuous data from top to bottom, the
other
(B) with simular data only dispersed randomly from top to bottom. What
I
would like to do is replace the data in column A with the contents of
column
B, only when there is data in the cell in column B, if there is no data I
want the data in column A left the way it is.
thanks in advance for the help.


You can do that directly... Copy the range you want from column B, click
the matching start cell in column A, then select Paste Special from the
Edit menu item... on the Paste Special dialog box, select Values from the
Paste section, None from the Operation section and check mark the Skip
Blanks box... click OK and you are done.

Rick



Rick Rothstein \(MVP - VB\)

if then question
 
Unless a blank in col B is NOT really a blank

I am newly returned to Excel after a long absence, so I am rusty. Can you
please tell me what you are referring to here? Thank you.

Rick


Don Guillett

if then question
 
Test both with one of the cells in col B that has been contaminated by
touching the space bar so that is not really blank.

--
Don Guillett
SalesAid Software

"Rick Rothstein (MVP - VB)" wrote in
message ...
Unless a blank in col B is NOT really a blank


I am newly returned to Excel after a long absence, so I am rusty. Can you
please tell me what you are referring to here? Thank you.

Rick



Rick Rothstein \(MVP - VB\)

if then question
 
Test both with one of the cells in col B that has been contaminated
by touching the space bar so that is not really blank.


Okay, I see what you were saying. If I smart, I would have guessed that was
what you meant by the Trim function call you made in your VBA code. Thanks
for getting back to me on this.

Rick



All times are GMT +1. The time now is 11:30 PM.

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