1

I am attempting to take the data from my input screen:

Input Screen

And transfer it to an excel worksheet to store the data. This is where I would like the data to go:

Output

I am currently using this code:

ActiveCell=TextBox1.Value
ActiveCell.Offset(0,1)=TextBox2.Value

But I need to keep doing this for every textbox which seems very inefficient.

Is there a more efficient way to transfer this data from the userform to the sheet?

Any help would be greatly appreciated. Thanks!

Robin Mackenzie
  • 18,801
  • 7
  • 38
  • 56
Snave
  • 11
  • 2
  • 1
    Without seeing more code, I'd just say take the data and put it directly into the cells. It would help greatly, and is recommended, to [avoid using `.Select`/`.Activate`](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros). Instead of using `ActiveCell`, use for example `Cells(2,2)` or whatever cell it is. – BruceWayne Apr 23 '17 at 21:49

1 Answers1

0

try the following syntax to loop through the textboxes

for i=0 to n ' n =number of textbox values to copy
   activecell.offset(0,i)=userform2.controls("textbox"& i+1).value
next i
h2so4
  • 1,559
  • 1
  • 10
  • 11