Using VBA macro to store data at a specified location

m1lky

New Member
Joined
Jan 28, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm upgrading an excel script. I am hoping to use Form Control buttons with VBA macro's to make my life a bit easier.
What I'm hoping to do is as follows. I expect to make the same calculation daily. I want to store the results of my calculation, (by pressing the button). The results should be stored in a row designated to the specified date.

In the Sample below:
- I have my calculation result (B1)
- I have manually specified the associated date (B2)

Now when I press my "Store calculation" button I wish to:

Save the result from B1, to the cell associated to (B2) (for this specific example that would be B14)

Kind regards to any and all help
1580238028079.png
 

Attachments

  • 1580237451666.png
    1580237451666.png
    16.2 KB · Views: 2

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this

VBA Code:
Private Sub CommandButton1_Click()
  If Range("B1").Value = "" Then
    MsgBox "Missing value"
    Exit Sub
  End If
  If Range("B2").Value = "" Then
    MsgBox "Missing Date"
    Exit Sub
  End If
  '
  Dim f As Range
  Set f = Range("A11:A" & Range("A" & Rows.Count).End(xlUp).Row).Find(Range("B2").Value, , xlFormulas, xlWhole)
  If Not f Is Nothing Then
    f.Offset(, 1).Value = Range("B1")
    MsgBox "Stored data"
  Else
    MsgBox "There is no date in column A"
  End If
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,232
Messages
6,123,763
Members
449,120
Latest member
Aa2

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