How to move data left if blank

keranali

Rules Violation
Joined
Oct 4, 2010
Messages
234
Office Version
  1. 365
Platform
  1. Windows
Hi Guys J2 to M2 has data in a row I want to be able to move data from the right to the left within those columns if the left cell is empty. How possible is this.

EXAMPLE

Excel Workbook
JKLM
2abcddefghijk
3abcddefghijk
Sheet3



Thanks
K
 
Hi no formulas have been used can I send a copy to you I know the VBA is working its just not applying to this sheet.

K
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
So it works on other sheets, just not this particular one?

Try

Code:
Application.EnableEvents = False
With Range("J:M")
    .Value = .Value
    .SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft
End With
Application.EnableEvents = True
 
Upvote 0
Same thing but I takes about 10 secs before the error shows when I click debug I am getting this line with the error.

.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft

Thanks
K
 
Upvote 0
Well, the error is still pretty self explainatory..

"No Cells Found" (This is the error right?)


That means there are no blank cells in the range J:M

If you see there are blanks in the range, pick one and note it's address (J20 or whatever).

What do these formulas return

=LEN(J20)
=CODE(J20)
=ISBLANK(J20)
=ISNUMBER(J20)
=ISTEXT(J20)

Where J20 is a cell you believe to be blank.
 
Upvote 0
Hi in 2006 I saw you had some input with a similar vba with eric van geit with the code as follows:

Sub fill_blanks()
'Erik Van Geit
'061109

'fill empty cells in column B with values of column A
'ASSUMPTIONS
'only values in column B (formulas will be converted)

Dim LR As Long
Dim rng As Range
Dim blanks As Range

LR = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("B1:B" & LR)

On Error Resume Next
Set blanks = rng.Cells.SpecialCells(xlCellTypeBlanks)
On Error GoTo 0

If blanks Is Nothing Then Exit Sub

'you cannot use blanks.Value = blanks.Value
'all cells would get the first value if blanks are not adjacent
blanks.FormulaR1C1 = "=RC[-1]"
rng.Value = rng.Value

End Sub

Can this code apply to my situation....

thanks
K
 
Upvote 0
OK, so you want to fill the blanks with whatever the value is to the right (or left) of the blank?

Try

Code:
With Range("J:M")
    .FormulaR1C1 = "=RC[-1]
End With

That will fill blanks with the value to the left.

Change -1 to 1 to make it fill with values to the right.
 
Upvote 0
Hi that formula takes information from I and populates all the cells till M this is what i am thinking of


Excel Workbook
JKLM
2ABCDEEFGHIJKLM
3NOPQRSTUV
4WXYZ
5
6ABCDEEFGHIJKLM
7NOPQRSTUVWXYZ
Sheet1



I believe something is wrong somewhere because I can't cut and paste values within the workbook do you know why is this like this.
 
Upvote 0
I believe first VBA is locking the copy and paste as well as right click cell to delete I am wondering if this is affecting.

Thanks
K
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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