how to copy row value until blank row vba

Status
Not open for further replies.

Shanaka Fernando

New Member
Joined
Sep 30, 2021
Messages
12
Office Version
  1. 2010
Platform
  1. Windows
i have vba code for copy cell value from multiple sheet to one sheet based on header

i need to change the vba code to copy row value until first blank row

ex- need copy
header "Item description" until "women bikini 2p hang"

1634136717639.png



Sub MoveToDestination()

Dim destinationSheet As Worksheet, destRow As Long, destCol As Variant
Dim ws As Worksheet, wsRow As Long, wsCol As Variant
Dim columnHeader As Variant

Set destinationSheet = ThisWorkbook.Worksheets("data")

For Each ws In ThisWorkbook.Worksheets
If Not ws Is destinationSheet Then
For Each columnHeader In Array("COLOR", "Item description")
With ws
wsCol = Application.Match(columnHeader, .Rows(17), 0)
If Not IsError(wsCol) Then
wsRow = .Cells(.Rows.Count, wsCol).End(xlUp).Row
destCol = Application.Match(columnHeader, destinationSheet.Rows(1), 0)
destRow = destinationSheet.Cells(destinationSheet.Rows.Count, destCol).End(xlUp).Row + 1
.Range(.Cells(18, wsCol), .Cells(wsRow, wsCol)).Copy destinationSheet.Cells(destRow, destCol)
Else
MsgBox "Column heading " & columnHeader & " not found in row 1 of " & .Name
End If
End With
Next
End If
Next
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Duplicate to: VBA to Copy Rows Until Blank Row

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread. If you do not receive a response, you can "bump" it by replying to it yourself, though we advise you to wait 24 hours before doing so, and not to bump a thread more than once a day.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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