How to ignore blank cells?

Adrian Low

New Member
Joined
Apr 30, 2019
Messages
23
Hi,

I am trying to ignore the blank cell whenever the marco finds it. I need is the output workbook to be copied a blank cell if the Input workbook has one. Instead of this, I am getting the output of values from the input that is in the subsequent cell and everything moves upwards.

https://imgur.com/a/t9Ezs1c

The picture above shows the input and the output file as you can see row "7" there are some blank values but the output instead of copying the blank cells it copy the value in the subsequent row and this makes everything moves upwards.

Thank you,
Adrian
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
It would help, if you were to supply your code ;)
 
Upvote 0
Hi this is the code.

'From here onwards my code did not detect the blank cells and instead of skipping it. it just copy the values onto it.

Code:
With wsInput
                    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
                    For Each C In .Range("F3:F" & LastRow)
                        wsOutput.Cells(C.Row, "I").Value = C & "" & C.Offset(0, 1)
                    Next C

                    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
                    For Each D In .Range("E3:E" & LastRow)
                        wsOutput.Cells(D.Row, "H").Value = D & ""
                    Next D

                    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
                     For Each A In .Range("G3:E" & LastRow)
                        wsOutput.Cells(A.Row, "G").Value = "01"
                    Next A

                    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
                       For Each V In .Range("D3:D" & LastRow)
                        wsOutput.Cells(V.Row, "E").Value = V & ""
                    Next V

                     LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
                       For Each Z In .Range("A3:A" & LastRow)
                        wsOutput.Cells(Z.Row, "D").Value = Z & ""
                    Next Z
                End With

            Dim Y As Range, M As Range

                With Ws2
                     LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
                       For Each Y In .Range("D3:D" & LastRow)
                        wsOutput.Cells(Y.Row, "C").Value = Y & ""

                    Next Y

                    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
                       For Each M In .Range("B3:B" & LastRow)
                        wsOutput.Cells(M.Row, "B").Value = M & ""

                    Next M
                End With

                With Ws2
                    LastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
                      For Each B In .Range("F3:F" & LastRow)
                       wsOutput.Cells(B.Row, "F").Value = Left(Workbooks("InputA.xls").Worksheets("Sheet0").Cells(B.Row, "G").Value, 1)
                    Next B
                End With
 
Last edited by a moderator:
Upvote 0
You are only having problems with cols B,C & F which are coming from Ws2 whatever that is, rather than wsInput.
 
Upvote 0
I don’t think is just that. Hmm do you know how can I let the code to copy blank cells too? Cause it is picking up values from the cells below and whole data is shifted upwards
 
Upvote 0
There is nothing in the code that you've shown, that would ignore blank cells.
So the problem lies elsewhere within the code.
 
Upvote 0
With Ws2
LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
For Each Y In .Range("D3:D" & LastRow)
If Len(Y.Value) = 0 Then
Set Y = Y.Offset(1, 0)
Else
wsOutput.Cells(Y.Row, "C").Value = Y & ""

Hi, I have tried this but it doesn't work. It still doesn't copy the blank cells instead taking values from the below row
 
Upvote 0
Can you please post the entire code that you are using.
 
Upvote 0

Forum statistics

Threads
1,214,622
Messages
6,120,572
Members
448,972
Latest member
Shantanu2024

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