ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   UserForm Data to Spreadsheet (https://www.excelbanter.com/excel-discussion-misc-queries/31890-userform-data-spreadsheet.html)

Andy Tallent

UserForm Data to Spreadsheet
 
Is it possible when writing Userform data elements to a spreadsheet to
specify exactly the cell you want the first piece of data to populate. I
have tried a number of methods which allocate the data to the first available
free cell or row but this is not exactly what I want to do here.

For example, I would like to specify Cell "C4" to receive the first piece of
data from the userform with subsequent pieces of data from that submission
populating "D4,E4,F4" etc. The next time data is submitted from the Userform
I would like it to start at "C5". Sorry for this lengthy explanation but any
help would be very much appreciated.

Kindest regards as always.
--
Andy Tallent

Tom Ogilvy

You would need to use code to write the data. It is unclear how you would
specify the location, but once you have that established, the code would
just be written to address a relative location to the specified cell.

Private Sub Commandbutton1_click()
Dim rng as Range
on Error Resume Next
set rng = application.Inputbox("select destination cell using mouse",
type:=8)
On Error goto 0
if not rng is nothing then
textbox1.Text = rng.Value
textbox2.Text = rng.offset(0,1).Value
textbox3.Text = rng.offset(0,2).Value
end if
Next

--
Regards,
Tom Ogilvy


"Andy Tallent" wrote in message
...
Is it possible when writing Userform data elements to a spreadsheet to
specify exactly the cell you want the first piece of data to populate. I
have tried a number of methods which allocate the data to the first

available
free cell or row but this is not exactly what I want to do here.

For example, I would like to specify Cell "C4" to receive the first piece

of
data from the userform with subsequent pieces of data from that submission
populating "D4,E4,F4" etc. The next time data is submitted from the

Userform
I would like it to start at "C5". Sorry for this lengthy explanation but

any
help would be very much appreciated.

Kindest regards as always.
--
Andy Tallent




Andy Tallent

Thank you Tom,

I reversed "textbox1.Text = rng.Value" to read "rng.Value = textbox1.Text"
and it worked a treat, thank you very much for the help.
--
Andy Tallent


"Tom Ogilvy" wrote:

You would need to use code to write the data. It is unclear how you would
specify the location, but once you have that established, the code would
just be written to address a relative location to the specified cell.

Private Sub Commandbutton1_click()
Dim rng as Range
on Error Resume Next
set rng = application.Inputbox("select destination cell using mouse",
type:=8)
On Error goto 0
if not rng is nothing then
textbox1.Text = rng.Value
textbox2.Text = rng.offset(0,1).Value
textbox3.Text = rng.offset(0,2).Value
end if
Next

--
Regards,
Tom Ogilvy


"Andy Tallent" wrote in message
...
Is it possible when writing Userform data elements to a spreadsheet to
specify exactly the cell you want the first piece of data to populate. I
have tried a number of methods which allocate the data to the first

available
free cell or row but this is not exactly what I want to do here.

For example, I would like to specify Cell "C4" to receive the first piece

of
data from the userform with subsequent pieces of data from that submission
populating "D4,E4,F4" etc. The next time data is submitted from the

Userform
I would like it to start at "C5". Sorry for this lengthy explanation but

any
help would be very much appreciated.

Kindest regards as always.
--
Andy Tallent






All times are GMT +1. The time now is 04:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com