code not working as I want

viper

Active Member
Joined
Feb 15, 2002
Messages
382
The following code I'm using to insert users data.
If textbox1.value > 0 and Textbox1.value < 86 then
ActiveSheet.cells(TextBox1.value + 8, 4).value = Textbox4.text
'check if cell has data already
If ActiveSheet.Cells(TextBox1.Value + 8, 4) <> "" Then
'if cell not blank insert new row
ActiveSheet.Cells(TextBox1.Value + 9).Select
With Selection.EntireRow.Insert
'now insert data into new row column 4
ActiveSheet.Cells(TextBox1.Value + 9, 4).Value = _
TextBox4.Text
End With
Else
ActiveSheet.Cells(TextBox1.Value + 8, 4).Value = _
TextBox4.Text
End If
it takes the user input in textbox1 and adds 8. So if the user input 1 the code would add 8 to get row 9, column 4 and then insert textbox4.text but if row 9, 4 is not blank then it will add 9 to get to the row below which would then be 10 and insert a new row then insert the data into the new row which would be 10, 4.

I am getting it to insert new rows but not at the point I need them.

any ideas?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,213,563
Messages
6,114,329
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top