VBA copying values only from multiple ranges ignoring empty/blank cells. Pls Help!

iCountWater

New Member
Joined
Aug 3, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Very new to VBA. Like... VERY! Have simplified what I'm actually working on in the hope that if anyone can solve my problem as presented I can work with that and further my own understanding of VBA. Need to copy from 9 different ranges that may have all data, some data or no data (see: attached image "sheet1") to a sequential list on other worksheet (see: attached image "sheet 2") ignoring empty/blank cells. Data in "Type" column of ranges is from drop-down lists, remaining data ("V1- V4") is auto populated accordingly via formulas. Need to copy the values only and, as mentioned ignore empty/blank. Managed to get ranges to copy but not ignoring empty/blanks. And the code is ugly. Really ugly. I need help.
Sheet1.PNG

Sheet2.PNG
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi & welcome to MrExcel.
How about
VBA Code:
Sub iCountWater()
   Dim Ary As Variant
   Dim i As Long
   
   Ary = Array("A3:E7", "G3:K7", "M3:Q7", "A11:E15", "G11:K15", "M11:Q15", "A19:E23", "G19:K23", "M19:Q23")
   
   For i = 0 To UBound(Ary)
      Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(5, 5).Value = Sheets("Sheet1").Range(Ary(i)).Value
   Next i
End Sub
 
Upvote 0
Solution
Hi & welcome to MrExcel.
How about
VBA Code:
Sub iCountWater()
   Dim Ary As Variant
   Dim i As Long
  
   Ary = Array("A3:E7", "G3:K7", "M3:Q7", "A11:E15", "G11:K15", "M11:Q15", "A19:E23", "G19:K23", "M19:Q23")
  
   For i = 0 To UBound(Ary)
      Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(5, 5).Value = Sheets("Sheet1").Range(Ary(i)).Value
   Next i
End Sub
Thanks so much! Works perfectly :)
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,517
Members
449,088
Latest member
RandomExceller01

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