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
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,239
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.
 

chrishartley999

New Member
Joined
Dec 23, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Here's a redacted copy of the sheets I'm working with, I'm pretty sure the share link should work

 

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,239
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
 

chrishartley999

New Member
Joined
Dec 23, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Thats working great, thank you. Im slowly starting to see how this language works
 

Watch MrExcel Video

Forum statistics

Threads
1,128,107
Messages
5,628,731
Members
416,333
Latest member
Time2Learn

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
Top