PDA

View Full Version : print data



Nader
01-15-2008, 06:57 AM
I tried this code to start form the 6 row but it didn't success
It works only from the second row
Dim j As Integer
j = 6
j = Sheets(1).UsedRange.Rows.Count + 1
Cells(j, 2).Value = TextBox1.Text

How to do this?

rconverse
01-15-2008, 11:08 AM
I am not an authority in Excel by any means, but why are you setting your variable j twice?

Dim j As Integer
j = 6
j = Sheets(1).UsedRange.Rows.Count + 1
Cells(j, 2).Value = TextBox1.Text

Are you trying to find the last used row, in other words it won't always be 6, and then add data from TextBox1?

Dim j As Integer
j = Sheets(1).UsedRange.Rows.Count + 1
Cells(j, 2).Value = TextBox1.Text

Can you set the range to the 6th row?

Dim j As Integer
j = 6
Cells(j, 2).Value = TextBox1.Text

HTH
Roger

Nader
01-15-2008, 11:46 AM
I'm trying to print the data from textbox to cells.Cell after cell,start from row6 . it mena if I insert george in texbox and press print command it will print it in cell in row6 then if I insert another data like john in texbox will print it in cell row7 and so ....

ProteanBeing
01-15-2008, 05:50 PM
rowcount = 6
do until isempty(cells(rowcount, 1))
rowcount = rowcount+1
loop
cells(rowcount, 1) = textbox1.value

Nader
01-16-2008, 07:28 AM
Thank you
may you help more
How can I make undo for this sub

ProteanBeing
01-16-2008, 10:42 AM
Create a global variable (lets call it LastRow)
Place this line at the end of the code
LastRow = rowcount

now you have a defined location of the last row edited. This variable will be accessible until the macro is complete. If you need it after that either save it to a text file or place it in a hidden cell.

Nader
01-17-2008, 07:23 AM
I'm sorry, I'm still beginner. How can I do this