Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Macro - copy cell contents IF

Hope you can help, need to move a value in one cell to another only IF the
first cell is not empty.

In a function it would be:

in cell B2 - - - - =IF(C2="","",C2)

What I have now:
Col1 Col2
AAA

BBB
CCC

What I would like to end up with:
Col1 Col2
AAA AAA

BBB BBB
CCC CCC

Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Macro - copy cell contents IF

You already have the formula. What is the problem?

Glen

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Macro - copy cell contents IF

Problem is, I need it in VBA instead of a function.

" wrote:

You already have the formula. What is the problem?

Glen


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro - copy cell contents IF


You could use a loop...see below

Sub Loop()
On Error Resume Next
Dim r As Variant
Dim WSN As Variant
Set WSN = Thisworkbook.Sheets("Sheet1") 'put the sheet name here
r = 1
Do
If WSN.Cells(r, 1).Value = "" Then
r = r + 1
Else:
WSN.Cells(r, 2).Value = WSN.Cells(r, 1)
r = r + 1
End If
Loop
End Sub

This would do what you want...If you need more help, let me know...

Scott Wagner Wrote:
Hope you can help, need to move a value in one cell to another only IF
the
first cell is not empty.

In a function it would be:

in cell B2 - - - - =IF(C2="","",C2)

What I have now:
Col1 Col2
AAA

BBB
CCC

What I would like to end up with:
Col1 Col2
AAA AAA

BBB BBB
CCC CCC

Thanks in advance!



--
dok112
------------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=513802

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Macro - copy cell contents IF

Is there a way to do this where I can be more specific?

Say only look at column F, and copy values to column D.

Any ideas?


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
Macro to remove contents of cell and move all other contents up one row adw223 Excel Discussion (Misc queries) 1 July 1st 05 03:57 PM
Macro to copy contents in current row to Sheet2 theDude[_2_] Excel Programming 1 May 31st 05 06:27 PM
Macro to copy cell contents number of columns Pierre Excel Programming 10 November 4th 04 10:54 PM
Using VB copy contents of a macro to workbook jminu_2k Excel Programming 2 September 7th 04 10:11 AM
Copy cell contents into Macro code Bob Leonard Excel Programming 2 December 1st 03 07:29 PM


All times are GMT +1. The time now is 01:10 PM.

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

About Us

"It's about Microsoft Excel"