Issue With Inserting Blank Cells when I Shift Cells Down One

bradlydraper

New Member
Joined
May 13, 2015
Messages
26
Currently, I have a code that looks something like this, though I can't post the code itself since it's on a work computer

Code:
Sheets("Sheet1").[D2].Offset(1).Insert Shift:=xlDown
Sheets("Sheet1").[D2] = TextBox1.Value

etc

So what that does is pushes my all the cells in column "D", excluding D1, down one row. I have this code assigned to a total of 4 different command buttons, each one writing their own complicated textbox value sentences.

The issue that I'm having is occasionally, and randomly (I honestly can't find a trend to the error), it will blank out the cell D2 and push it down as a blank cell, and push everything else out normally.

For example, I'll have 20 Rows full of text, then I'll click the same command button again (or a different one) and it will randomly push down a blank cell rather than the cell that had text in it. I've tried changing simple formatting, adding
Code:
CopyOrigin:=xlFormatFromLeftOrAbove
amongst many other things, but nothing really seems to be working and i'll still randomly push down a blank cell in Column D.

Any help is much appreciated, thank you
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Correction, it never inserts the blank cell while I keep the userform open and switch pages, it only happens randomly when I reopen it and when I hit the command button the first time to write the data again to D2.

Other than reopening it and doing it for the first time and it (randomly) inserts and pushes down the blank cell, this code has absolutely no issues.
 
Upvote 0
I doubt that's happening randomly. More likely it happens when there is nothing in TextBox1 (TextBox1.Value = ""), as it should, since your second line then returns "" to D2.
 
Upvote 0
It's not blank textboxes. It makes the cell blank then pushes it down. It doesn't push D2 down then push a blank, it makes D2 blank then pushes that, so the data gets erased.It honestly is random from what I can tell. I do the exact same process with opening the userform, and sometimes it blanks the cell and pushes it down, sometimes it doesn't.

I appreciate the recommendation, though
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,853
Members
449,051
Latest member
excelquestion515

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