Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to fill cell values from textbox vba form

Status
Not open for further replies.

bsurfn99

Technical User
Mar 23, 2005
34
US
I have a script that takes textbox entries from a vbaform and finds the first blank row and places the txtbox value in the cell.

What I need to do it place all form values into the same row as the first blank column.

Here is a visual example of what I need database to do.

column-> A | B | C |
row 1 x x x
row 2 x x
row 3 x x x

Currently my code would place row 3 B column x into row 2, I need to fix this. Here is an example of the code format I am using.

<CODE>
Dim longpos As String

longpos = txt_transcost.Text
'column A
'find first blank longpos
Let counter = 3
Set curcell = Worksheets("database").Cells(counter, 3)
Do Until curcell.Value = ""
counter = counter + 1
Set curcell = Worksheets("database").Cells(counter, 3)
Loop
Set curcell = Worksheets("database").Cells(counter, 3)

'post data
Worksheets("database").Cells(counter, 3).Value = UCase(longpos)

'Column B
'find first blank variable1
Let counter = 3
Set curcell = Worksheets("database").Cells(counter, 4)
Do Until curcell.Value = ""
counter = counter + 1
Set curcell = Worksheets("database").Cells(counter, 4)
Loop
Set curcell = Worksheets("database").Cells(counter, 4)

'post data
Worksheets("database").Cells(counter, 4).Value = variable1

'Column C (not shown)

</CODE>

Any ideas how I can fix this? Thanks for your help


 
A starting point:
Code:
counter = 3
With Worksheets("database")
  Do Until .Cells(counter, 3) & .Cells(counter, 4) & .Cells(counter, 5) = ""
    counter = counter + 1
  Loop
  'post data
  .Cells(counter, 3).Value = UCase(longpos)
  .Cells(counter, 4).Value = variable1
  .Cells(counter, 5).Value = variable2
End With

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Just wanted to say thanks! That worked great, and it's so much simpler. thanks again.

-bsurfn99
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top