Inserting data to specific Row & Column

Damocles2021

New Member
Joined
Mar 6, 2021
Messages
4
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I would appreciate some help, I have a spreadsheet named ‘Visits’ which has approx 400 columns (B–OC) and Names in Columns A2 – A36, data is entered into the userform which is then transferred to the sheet, I have 1 combox on the form, ‘cboName’ (populated with data from Column A) and 2 textboxes –‘txtSite’, Which is the header for the Columns, and ‘txtDate’. So user choses their name from (cboName) dropdown and then types the site name and date in textboxes, after pressing enter I would like the date to be entered in the cell relating to the site and name. If the sheet only had a few columns it wouldn’t be an issue but 400 odd columns!

If possible pointers in the right direction would help, I’m relatively new to learning VBA and enjoy the challenge of trying to work it out for myself, waiting for delivery of Microsoft Excel 2019, VBA & Macros) Googling just seems to throw up how to fill text boxes in user forms or how to find last row, or how to insert row etc, which I know how to do. (The thing what I have learned though is that there seems to be various methods to get the same results, 😕. Even had trouble wondering what to name this thread title as!! 😆)
Any and all help greatly appreciated.
Regards
Dam
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
10,311
Place this macro in the userform code window. First select the name, then the site and lastly the date pressing the RETURN key after each entry.
VBA Code:
Private Sub txtDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim rName As Range, rSite As Range
    With Sheets("Visits")
        Set rName = .Range("A:A").Find(cboName.Value, LookIn:=xlValues, lookat:=xlWhole)
        Set rSite = .Rows(1).Find(txtSite.Value, LookIn:=xlValues, lookat:=xlWhole)
        .Cells(rName.Row, rSite.Column) = txtDate.Value
    End With
End Sub
 
Solution

Damocles2021

New Member
Joined
Mar 6, 2021
Messages
4
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Place this macro in the userform code window. First select the name, then the site and lastly the date pressing the RETURN key after each entry.
VBA Code:
Private Sub txtDate_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Dim rName As Range, rSite As Range
    With Sheets("Visits")
        Set rName = .Range("A:A").Find(cboName.Value, LookIn:=xlValues, lookat:=xlWhole)
        Set rSite = .Rows(1).Find(txtSite.Value, LookIn:=xlValues, lookat:=xlWhole)
        .Cells(rName.Row, rSite.Column) = txtDate.Value
    End With
End Sub
Mumps.. you are a legend.. I was playing with similar code but couldnt get the syntax :p
Very much appreciated.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,123
Messages
5,640,245
Members
417,131
Latest member
Seanr19871

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