VBA User Form - Finding cell and inserting data

chrishartley999

New Member
Joined
Dec 23, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,
I'm very new to VBA, as I have only now encountered a project that needs it for ease of use by a user. I'm pretty fluent in standard formulas, but VBA has me stumped in terms of the language/commands I need to make this happen.

I have quite a decently sized workbook that will act as a user/client's nutrition and exercise yearly planner and tracker (i.e. personal database almost). The data is to be entered by the user periodically/weekly from the user form. I'm looking to insert data ('Activity Level:') from a combo box (named "Activity") to the appropriate cell on the sheet "Food", dependent on the 'Week Start:' combo box (named "WeekStartDropDown") date that is selected. Due to the original setup of the sheets/workbook I'm thinking of searching for the date selected (since there'll never be a duplicate of that date) in the "Food" sheet, offset the selection from column AC to P, then when the user hits the continue button to enter the data in that cell.

Pics attached for reference, thanks in advance :)

Weekly Data Entry.png
IMG_20201224_004706.jpg
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
It would be easier to help and test a possible solution if you could upload a copy of your file (de-sensitized if necessary) to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here.
 
Upvote 0
Try:
VBA Code:
Private Sub ContinueButton_Click()
    Dim rDate As Range
    Set rDate = Sheets("Food").Range("AC:AC").Find(CDate(WeekStartDropDown.Value), LookIn:=xlValues, lookat:=xlWhole)
    If Not rDate Is Nothing Then
        Sheets("Food").Range("P" & rDate.Row) = Activity.Value
    End If
    MsgBox "Data has been entered.", vbDefaultButton1, "Success"
    Unload UserDataEntry
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,387
Messages
6,124,637
Members
449,177
Latest member
Sousanna Aristiadou

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