Saving old values with VBA?

Ramballah

Active Member
Joined
Sep 25, 2018
Messages
311
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I have an issue. I have made a chart for a game im playing. when i win a match i will type in W and it will automatically show me how much money i made with the use of IF functions. if i put in an L it will do for losing. like this: https://ibb.co/gcBD2U

As you can see i have multiple charts to the right. in my main sheet i will put in the W or L and then in this sheet it will be copied to. But i want this information to be copied to the next chart if i put in new information in the main sheet.

So: In the main sheet i win 5 times so the first 5 are W. in this extra sheet in the first chart it will be the same because of my if functions.
Now if i change them to 5 times lose i want the 5 wins to be saved in the next chart. If i then get another 5 wins i want the 5 wins to go to the next chart and the 5 loses go to the next chart etc. so they keep moving to the next chart. So i can keep track of my total record. and not only in a session. I dont want to copy and paste my charts everytime because that will be bothersome. So if this is possible let me know. If i need to provide more information ask me! I am not really familliar with VBA yet. im trying to learn it through some online tutorials and stuff.

Thanks for reading hope u guys can help!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Or perhaps its possible to use a copy with values only? Like when my main chart is filled it will copy it to other sheet but only with the values. And then when i fill it again it will copy that one to there aswell but then i still have the old one? I'm not sure whats possible and whats not :l
 
Upvote 0
Code:
Sub Range_Copy_Example()    Dim note As String
    note = Range("B2")
    'This copies a cell and removes it.
    If note = "" = False Then
        Range("K2:K6").Copy Range("T2:T6")
        Range("K2:K6").ClearContents
    End If
    
End Sub
I have tried something my self. I'm not sure if im going into the right direction my self. But is it possible doing like this but with alot of ifs xD?
 
Upvote 0
I am still not sure if it works. Does any1 got any suggestions? Perhaps its possible to make an if with it. If that chart has information it it it will be copied to the next chart or something?
 
Upvote 0
Is it possible to make a macro automatic? So it activates itself without me pressing a button to activate it? So when an IF function is true the macro will do its thing without me pressing the button??
 
Upvote 0
Code:
Sub Range_Copy_Example()    Dim First_Chart As String, Second_Chart As String, Third_Chart As String
    Dim Fourth_Chart As String
    First_Chart = Range("B2")
    Second_Chart = Range("K2")
    Third_Chart = Range("T2")
    Fourth_Chart = Range("B104")
    'This copies a cell and removes it.
    If Fourth_Chart = "" = True And Third_Chart = "" = False Then
        Range("T2:T6").Copy Range("B104:B109")
        Range("T2:T6").ClearContents
        Range("K2:K6").Copy Range("T2:T6")
        Range("K2:K6").ClearContents
        Range("B2:B6").Copy Range("K2:K6")
        Range("B2:B6").ClearContents
    ElseIf Third_Chart = "" = True And Second_Chart = "" = False Then
        Range("K2:K6").Copy Range("T2:T6")
        Range("K2:K6").ClearContents
        Range("B2:B6").Copy Range("K2:K6")
        Range("B2:B6").ClearContents
    ElseIf Second_Chart = "" = True And First_Chart = "" = False Then
        Range("B2:B6").Copy Range("K2:K6")
        Range("B2:B6").ClearContents
    
    End If
    
End Sub
I now have made it into this. This is for only 4 charts to test really. But it works and im glad with that. However i need to press a button my self which i kinda dont want. And is it possible to shorten this because i need it basically for like 50-500 charts or something XD
 
Upvote 0

Forum statistics

Threads
1,214,645
Messages
6,120,711
Members
448,984
Latest member
foxpro

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