NEED HELP :) ! Macro problem

colerainescotty

New Member
Joined
Feb 25, 2009
Messages
10
Hi everyone, i hope i am posting in the right place.

Heres the problem, i have created an excel 2007 document to keep track of savings for my new car. The only problem i am having is with my cell copying. I know how to copy from one cell to another, however i have a balance e.g $248.00 which is updated from another sheet called update accounts. Its basically a cell which i want to copy then add to existing balance so it updates. E.g if i go to update accounts and input $400 then i want this to add on to the $248 which is on another sheet called status.

Excel mentioned something about continuous loops or turn something off as the calculation would not be correct but that is more than likely the wrong thing. I have tried doing it manually with the Macro recording feature to no avail.

When i recorded my macro i tried clearing the cells after i used them to store the values so it didnt keep adding on etc. I realise im probably making this sound extremely complicated, so sorry in advance.

I hope someone can tell me of a better way round this problem and if i havnt explained anything please do let me know so i can clarify.

Here is the macro code i recorded to try and accomplish my task:

Sub MacroSaveMoney()
'
' MacroSaveMoney Macro
'
'
Sheets("Update Accounts").Select
Range("E7:G7").Select
Selection.ClearContents
Range("E13:G13").Select
Selection.ClearContents
Range("E7:G7").Select
Selection.Copy
Sheets("Status").Select
Range("B10:D10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("E8:F8").Select
Application.CutCopyMode = False
Selection.Copy
Range("E10").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("D13").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = ""
Range("E8:F8").Select
ActiveCell.FormulaR1C1 = "=R[2]C[-3]+R[2]C"
Range("E10").Select
Range("B10:D10").Select
Selection.ClearContents
Sheets("Update Accounts").Select
Range("E7:G7").Select
Selection.ClearContents
Range("E7:G7").Select
Selection.ClearContents
Range("E13:G13").Select
Selection.ClearContents
End Sub

Thanks for help in advance :)
Ryan
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Problem Solved !!

Got the problem sorted after hours of research lol

Heres the code for future reference for any other developer !


Sub addMoney()

Dim barclaysBond As Single, studentSaver As Single
barclaysBond = Worksheets("Update Accounts").Range("E7").Value + Worksheets("Status").Range("E8").Value
studentSaver = Worksheets("Update Accounts").Range("E13").Value + Worksheets("Status").Range("E6").Value
Worksheets("Status").Range("E8").Value = barclaysBond
Worksheets("Status").Range("E6").Value = studentSaver
End Sub
 
Upvote 0
Cleaned up the macro code a little bit. Hopefully accurately :eeek:

Code:
Sub MacroSaveMoney()
  With Sheets("Update Accounts")
    .Range("E7:G7").ClearContents
    .Range("E13:G13").ClearContents
    .Range("E7:G7").Copy
  End With
  
  With Sheets("Status")
    .Range("B10:D10").PasteSpecial Paste:=xlPasteValues
    .Range("E8:F8").Copy
    .Range("E10").PasteSpecial Paste:=xlPasteValues
    .Range("D13").FormulaR1C1 = ""
    .Range("E8").FormulaR1C1 = "=R[2]C[-3]+R[2]C"
    .Range("B10:D10").ClearContents
  End With
  
  With Sheets("Update Accounts")
    .Range("E7:G7").ClearContents
    .Range("E13:G13").ClearContents
  End With
End Sub

What I don't understand is why are you clearing cell content in Update Accounts E7:G7, prior to copying it? And why are you doing it again at the end?
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top