Processing
 

Input box value insert in the next empty cell in row to the right

24/08/2016 13:35#1

Joined at: 6 months ago

Post: 1

Thank: 0

Thanked: 0

I am trying to add to the next empty cells to the right, the data from the user form text box, if data already exists. Meaning if "E1" is has date, add to "F1" and so on, but only is the range "E1:S1".

Here is a screenshot of the report:

Input box value insert in the next empty cell in row to the right

And here is what I've got so far (but it stops as E1):

Private Sub CommandButton1_Click()      If Range("E1") = "" Then Range("E1") = UserForm2.TextBox1.Value Else     Range("E1").End(xlToRight) = UserForm2.TextBox1.Value     If Range("E2") = "" Then Range("E2") = UserForm2.TextBox2.Value Else     Range("E2").End(xlToRight) = UserForm2.TextBox2.Value End Sub 
24/08/2016 13:48Top#2

Joined at: 12 months ago

Post: 21

Thank: 0

Thanked: 0

The End(xlToRight is only going to the end of the populated cells not the next open one. You need to move one more column over after finding the last populated cell. Use Cells() and I prefere staring at the furthest column and coming back.

Private Sub CommandButton1_Click()      If Range("E1").Value = "" Then Range("E1").Value = UserForm2.TextBox1.Value Else     Cells(1, Cells(1, Columns.Count).End(xlToLeft).Column + 1).Value = UserForm2.TextBox1.Value     If Range("E2").Value = "" Then Range("E2").Value = UserForm2.TextBox2.Value Else     Cells(2, Cells(2, Columns.Count).End(xlToLeft).Column + 1).Value = UserForm2.TextBox2.Value End Sub 
Similar articles

Excel More conditions in one formula?

6 months ago - Reply: 2 - Views: 172

Get Workbook reference from Open File dialog

6 months ago - Reply: 2 - Views: 131

Add Calculated Field To Pivot Table

6 months ago - Reply: 0 - Views: 7

Nested IF Functions in Excel not working

6 months ago - Reply: 3 - Views: 164

Formulating Date in Excel 2013

7 months ago - Reply: 2 - Views: 88

VB6 extracts in Excel 2013

7 months ago - Reply: 2 - Views: 153

Excel 2013 : Pull Matching Data from Column

7 months ago - Reply: 1 - Views: 23

excel search and copy in/from another file

7 months ago - Reply: 0 - Views: 1

Buggy PivotTable.ColumnRange

7 months ago - Reply: 0 - Views: 6

Excel static conditional formatting area

7 months ago - Reply: 0 - Views: 8

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re