Store Value and Shift down cell value

chucklesOU

New Member
Joined
Oct 19, 2023
Messages
3
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hey guys, I'm writing a code to count and store values to reference how often something is referenced in a class. I'm trying to write a code that counts with one button (this is complete) and stores historical values in another column. This is where I'm having issues. My counter is set in B2, and I have F2:F200 set aside for value storage. I'd like a button to automatically store the value from B2 to the next available F column cell and automatically reset B2 to 0. Is this possible? Thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Welcome to the Board!

I think it would be most helpful if we could see an example of what your data looks like and an example of your expected output.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Welcome to the Board!

I think it would be most helpful if we could see an example of what your data looks like and an example of your expected output.
MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Hi Joe4, thanks for the quick reply! There is no data to work with yet, so that's quite difficult to do. Here's the best way I can explain it:
My professor mentions Fish Fingers every class. As a fun side project, I wanted to have a button to count, in integers, how many times he says this.
For every time I press the button, it adds 1 to B2.
The problem I'm having is not knowing how to write the second part of the program:
I want a button to store the value from B2 at the end of class, and place it in the F column automatically before resetting B2 to for next class. When the value is stored in the F column, the next class should automatically have the new value stored directly underneath the previous class's final value.
I hope this helps!
 
Upvote 0
Try this:
VBA Code:
Sub AddTotal()
    Cells(Rows.Count, "F").End(xlUp).Offset(1, 0).Value = Range("B2").Value
    Range("B2").Value = 0
End Sub
 
Upvote 0
Solution
Try this:
VBA Code:
Sub AddTotal()
    Cells(Rows.Count, "F").End(xlUp).Offset(1, 0).Value = Range("B2").Value
    Range("B2").Value = 0
End Sub
Sorry for the delay, tested this in class today and it worked perfectly! Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,122,998
Members
449,092
Latest member
masterms

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