Inserting value at end of range

T

Todd Huttenstine

Hey guys

Lets say I have Range A1:A100 and a textbox(Textbox1).
Currently there are values in A1:A25. I need for for
TextBox1 value to be inserted in the next empty cell in
the range. The next empty cell in the range is A26, so
therefor this is where I would like Textbox1.value to be
inserted.

How would write this?

I usualy just do a count formula+1 in any cell and have
the vba code refer to that cell as the location for the
next value to be inserted, but this can clutter up my
worksheet with variables.

Thanx

Todd Huttenstine
 
G

Gord Dibben

Todd

Sub find_last_plus_one()
Cells(Rows.Count, 1).End(xlUp) _
.Offset(1, 0).Activate
End Sub

Will activate first blank cell in column A

Gord Dibben XL2002
 
T

Todd Huttenstine

Ok thanx, one last question...

I also have 1 checkbox1. How do I get it to perform that
code if checkbox1 is checked? If checkbox1 is not
checked, dont do the code.

Thanx

-----Original Message-----
Try this

Range("A" & Rows.Count).End(xlUp)(2) = TextBox1.Value


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)




"Todd Huttenstine" <[email protected]>
wrote in message [email protected]...
 
C

Chip Pearson

Todd,

Use something like

If Me.CheckBox1.Value = True Then
Range("A" & Rows.Count).End(xlUp)(2) = TextBox1.Value
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
M

MSP77079

That works just fine ... unless you have more data below the first blan
row, in which case you end up appending the new data at the very botto
instead of the relative bottom ... if you know what I mean.

I would suggest, instead ...

Dim myRange as Range

Range("A1").Select
Set myRange = ActiveCell.CurrentRegion
LastRow = myRange.Cells(myRange.Cells.Count).Row

the, insert the new data at LastRow +
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top