VBA Copy paste to a table but ignore if blank

Melimob

Active Member
Joined
Oct 16, 2011
Messages
395
Office Version
  1. 365
Hi All

I have a table which I want to copy a range from into another table however if the column (cell) value is blank I want to skip/ignore?

Is this possible?

Many thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi,

The answer with Excel ... is always ...Yes ...

Have you tried Before the Paste... to only Select the cells you require ..

with Range.SpecialCells() probably xlNumbers

https://docs.microsoft.com/en-us/office/vba/api/excel.range.specialcells


thanks again James but as I said in my other post. I think this level is beyond me and I'm trying to run before I can walk.

So what I'm opting for now is simply (she says 'simply' :) )

Take column A values (I have this in a table and it's my 1st column of table)
copy paste special to two places on my destination table on another sheet into the last available row.

Trouble is, I have a total row on my destination table so I think I need to write an if to say if there is a total row, remove and then copy and paste then add back in total row.
else no total row then copy and paste and add total row?

any advice gratefully received I've spent hours on this and think I have confused myself!
 
Upvote 0
Hello again,

Below is a macro to adapt to your specific situation

Code:
Sub LoopTable()
Dim i As Long, j As Long
  
  For i = 2 To Range("Table1").Rows.Count
     For j = 1 To Range("Table1").Columns.Count
        If Cells(i, j).Value <> "" Then
            MsgBox Cells(i, j).Value
        End If
     Next j
  Next i
End Sub

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

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