VBA search between blank rows for data and copy and paste

ckdragon

New Member
Joined
Apr 3, 2022
Messages
37
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi team,

Wondering if it is possible to have a VBA to look in between blank rows and return specific cells in a copy paste function to another sheet.

I essentially need a VBA that will search between blank rows and return specific cells and copy them to another sheet

The paste format would be just into column A, B, C, D, E, F, G, H all on the same row starting in row 2.

I have highlighted the cells that need to be copied across for reference in the minisheet below.

The columns start at A row 2 (I dont know why that didnt copy across in the minisheet - sorry!)

Any help would be greatly appreciated.

THANK YOU



Truck 1Community3/28/2210:36:58 AM3/28/2210:53:45 AMBase 1 Stop 0:16:4712.058140483
Truck 1Community3/28/2211:01:03 AM3/28/2211:50:35 AMStop Stop 0:49:3246.73140529
Truck 1Community3/28/2211:59:26 AM3/28/2212:09:47 PMStop Stop 0:10:216.738140536
Truck 1Community3/28/2212:48:17 PM3/28/2212:59:53 PMStop Stop 0:11:366.716140543
Truck 1Community3/28/221:07:56 PM3/28/221:26:54 PMStop Stop 0:18:5818.372140561
Truck 1Community3/28/221:40:03 PM3/28/222:01:16 PMStop Stop 0:21:134.635140566
Truck 1Community3/28/222:09:17 PM3/28/222:32:37 PMStop Base 1 0:23:2018.153140584
113.402
Truck 1Community3/28/227:18:42 PM3/28/227:56:35 PMBase 1 Stop 0:37:5334.283140618
Truck 1Community3/28/2210:24:50 PM3/28/2210:52:35 PMStop Base 1 0:27:4534.145140652
68.428
Truck 1Community3/29/228:58:36 AM3/29/229:13:02 AMBase 1 Stop 0:14:2610.613140663
Truck 1Community3/29/2210:30:01 AM3/29/2210:42:32 AMStop Stop 0:12:3110.385140673
Truck 1Community3/29/2211:42:14 AM3/29/2211:46:54 AMStop Base 1 0:04:401.935140675
22.933
Truck 1Community3/30/229:34:36 AM3/30/229:35:33 AMBase 1 Base 20:00:570.295140676
0.295
Truck 1Community3/30/229:46:18 AM3/30/229:47:14 AMBase 2Base 1 0:00:560.323140676
0.323
Truck 1Community3/30/2210:44:12 AM3/30/2210:55:36 AMBase 1 Stop 0:11:249.554140686
Truck 1Community3/30/2211:15:58 AM3/30/2211:30:14 AMStop Stop 0:14:1613.02140699
Truck 1Community3/30/2212:30:01 PM3/30/2212:37:27 PMStop Stop 0:07:264.715140703
Truck 1Community3/30/2212:55:26 PM3/30/2212:58:09 PMStop Base 1 0:02:431.248140705
28.537
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I dont know why that didnt copy across in the minisheet
Looks like you clicked 'Table Only' on the Xl2bb toolbar, not 'Mini Sheet'

Assuming that original data is on Sheet1 and you want the results on Sheet2, try this with a copy of your workbook.

VBA Code:
Sub GetSectionData()
  Dim rA As Range
  
  For Each rA In Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
    With rA
      Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 8).Value = Array(.Cells(1, 1), .Cells(1, 3), .Cells(1, 4), _
        .Cells(.Rows.Count, 5), .Cells(.Rows.Count, 6), .Cells(1, 7), .Cells(.Rows.Count, 8), .Cells(.Rows.Count + 1, 10))
    End With
  Next rA
End Sub
 
Upvote 0
Solution
I literally do not have enough words to thank you.

This works PERFECTLY.

Showed me some errors in my data too, which has now created more work for me but I would much rather know now.

THANK YOU AGAIN!


Looks like you clicked 'Table Only' on the Xl2bb toolbar, not 'Mini Sheet'

Assuming that original data is on Sheet1 and you want the results on Sheet2, try this with a copy of your workbook.

VBA Code:
Sub GetSectionData()
  Dim rA As Range
 
  For Each rA In Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
    With rA
      Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 8).Value = Array(.Cells(1, 1), .Cells(1, 3), .Cells(1, 4), _
        .Cells(.Rows.Count, 5), .Cells(.Rows.Count, 6), .Cells(1, 7), .Cells(.Rows.Count, 8), .Cells(.Rows.Count + 1, 10))
    End With
  Next rA
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,124
Members
453,021
Latest member
Justyna P

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