Home > database >  How can i record conditional data in a list with vba code?
How can i record conditional data in a list with vba code?

Time:03-23

Following this creation : enter image description here

in this case, as the employee is from the AA company, he will register in the "AA list": enter image description here

CodePudding user response:

To save the data from the "Meal Register" page to the correct sheet, you'll want something like this. I'm typing the VBA here, so It's not tested, but you should see the process. The example assumes the meal register is the active sheet

You should definitely set up data validation on cell K9 to be sure your company names are entered correctly.

dim s as worksheet
set s = thisworkbook.worksheets("List_" & range("K9").value)

dim row as long
row = s.cells(s.rows.count, "B").end(xlup).row   1

s.cells(row,"B").value = range("C7").value
s.cells(row,"E").value = range("C9").value
s.cells(row,"P").value = range("Q21").value
s.cells(row,"S").value = range("Q3").value
  • Related