Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 148
Default Need a macro to copy cells

I have numbers spread thruout col A, with many blank cells in between the data.
As time goes on I will add numbers in col B. In most cases there could be a
number in col B where there is none in col A(adjacent cell)
I would like to have a macro copy the numbers from col B to col A. If there
already is a number in col A I would like the number in col a to be added to
the number in col B
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,510
Default Need a macro to copy cells

Need to confirm a couple of thing.

"If there already is a number in col A I would like the number in col a to
be added to the number in col B". Do you mean if 5 exists in col A and you
insert 10 in col B then col B becomes 15?

What is to occur if there is an existing number in col B and you edit it?


--
Regards,

OssieMac


"pcor" wrote:

I have numbers spread thruout col A, with many blank cells in between the data.
As time goes on I will add numbers in col B. In most cases there could be a
number in col B where there is none in col A(adjacent cell)
I would like to have a macro copy the numbers from col B to col A. If there
already is a number in col A I would like the number in col a to be added to
the number in col B
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 148
Default Need a macro to copy cells

Once the daily input in Col B was made and the data moved to Col A, the data
in col B would be erased- no editing would take place


"OssieMac" wrote:

Need to confirm a couple of thing.

"If there already is a number in col A I would like the number in col a to
be added to the number in col B". Do you mean if 5 exists in col A and you
insert 10 in col B then col B becomes 15?

What is to occur if there is an existing number in col B and you edit it?


--
Regards,

OssieMac


"pcor" wrote:

I have numbers spread thruout col A, with many blank cells in between the data.
As time goes on I will add numbers in col B. In most cases there could be a
number in col B where there is none in col A(adjacent cell)
I would like to have a macro copy the numbers from col B to col A. If there
already is a number in col A I would like the number in col a to be added to
the number in col B
Thanks

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,510
Default Need a macro to copy cells

You didn't answer my question on the following.

"If there already is a number in col A I would like the number in col A to
be added to the number in col B". Do you mean if 5 exists in col A and you
insert 10 in col B then col B becomes 15? Or do you mean that col A becomes
15?

--
Regards,

OssieMac


"OssieMac" wrote:

Need to confirm a couple of thing.

"If there already is a number in col A I would like the number in col a to
be added to the number in col B". Do you mean if 5 exists in col A and you
insert 10 in col B then col B becomes 15?

What is to occur if there is an existing number in col B and you edit it?


--
Regards,

OssieMac


"pcor" wrote:

I have numbers spread thruout col A, with many blank cells in between the data.
As time goes on I will add numbers in col B. In most cases there could be a
number in col B where there is none in col A(adjacent cell)
I would like to have a macro copy the numbers from col B to col A. If there
already is a number in col A I would like the number in col a to be added to
the number in col B
Thanks

  #5   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 245
Default Need a macro to copy cells

Perhaps the OP solved the problem? Irrespective, I am also having problems
understand the logic of the request.

My interpretation of the question
1) If A is blank add B to A and store in A. {my comment - delete Column B
value?}

2) If there is a number in A, add it to column B. {my comment - this seems
reverse logic of the above BUT, the OP may have a good reason for doing it
this way and clearly seems to indicate copy rather than add}

Code to do this:

Sub AddBtoAorAtoB()
Dim rws As Long

rws = ActiveSheet.UsedRange.Rows.Count


For i = 1 To rws
If ActiveSheet.Range("A" & i) 0 Then
If ActiveSheet.Range("B" & i) & "" = "" Then
ActiveSheet.Range("B" & i) = ActiveSheet.Range("A" & i)
Else
ActiveSheet.Range("A" & i) = ActiveSheet.Range("B" &
i).Value + ActiveSheet.Range("A" & i)
End If
Else
ActiveSheet.Range("A" & i) = ActiveSheet.Range("B" & i).Value
End If
Next i

End Sub



If the OP just wants to add the value in column B to the value in column A,
whether either of the values is blank is irrelevant:

Sub SimplyAddBtoA()
Dim rws As Long

rws = ActiveSheet.UsedRange.Rows.Count


For i = 1 To rws

ActiveSheet.Range("A" & i) = ActiveSheet.Range("B" & i).Value +
ActiveSheet.Range("A" & i)
'uncomment below to prevent 0 values
'If ActiveSheet.Range("A" & i) = 0 Then ActiveSheet.Range("A" & i) =
""
'to prevent repeated adding of column B values
' clean up as you go
ActiveSheet.Range("B" & i).Value = ""


Next i

End Sub


The ball is in pcor's court. If both the above missed the specification,
pcor may help by supplying sample data (this is how it looks like now, this
is how it should look after the code runs) .

--
Steve

"OssieMac" wrote in message
...
You didn't answer my question on the following.

"If there already is a number in col A I would like the number in col A to
be added to the number in col B". Do you mean if 5 exists in col A and you
insert 10 in col B then col B becomes 15? Or do you mean that col A
becomes
15?

--
Regards,

OssieMac


"OssieMac" wrote:

Need to confirm a couple of thing.

"If there already is a number in col A I would like the number in col a
to
be added to the number in col B". Do you mean if 5 exists in col A and
you
insert 10 in col B then col B becomes 15?

What is to occur if there is an existing number in col B and you edit it?


--
Regards,

OssieMac


"pcor" wrote:

I have numbers spread thruout col A, with many blank cells in between
the data.
As time goes on I will add numbers in col B. In most cases there could
be a
number in col B where there is none in col A(adjacent cell)
I would like to have a macro copy the numbers from col B to col A. If
there
already is a number in col A I would like the number in col a to be
added to
the number in col B
Thanks


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
Do I use a formula or a macro to copy cells? ak_edm Excel Discussion (Misc queries) 3 April 7th 09 08:47 PM
Function or macro to copy cells... ak_edm Excel Discussion (Misc queries) 0 April 2nd 09 10:14 PM
macro to copy following cells in the same column pol Excel Discussion (Misc queries) 4 October 15th 08 06:11 PM
Copy Selected cells down a row with macro DB33 Excel Discussion (Misc queries) 1 February 15th 06 05:33 PM
Macro to copy cells Esrei Excel Discussion (Misc queries) 2 August 11th 05 11:31 AM


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