Looping help to skip blank rows vba

Vlr516

New Member
Joined
Sep 11, 2017
Messages
22
I am moving data from a source sheet to my activesheet. When I do, any blank rows on my source sheet are copying over as well. I do not want this. I want on my activesheet for all the data to be compacted together. How do I do this--what am I missing in my code below?

Sub SkipBlankRows
Dim finalrow as long

finalrow = sourcesheet.cells(rows.count, 3).End(xlup).row

for i=6 to finalrow
If sourcesheet.cells(i,3)<> "" Then
Activesheet.Cells(i,3).value = sourcesheet.cells(I,3).value​
End if​
Next I
End Sub
 
2 billion, wow. I'm glad I don't have look through that much data on what I am doing.

Below is the code that worked for skipping the blank rows. At the end, I would like to copy the activesheet which is in the same workbook as the sourcesheet, and create its own file using a concatenation of the sourcesheet name and the activesheet name. I added the code to copy at the end below but I am not sure what to do next.


Code:
Sub SkipBlankRows
 Dim finalrow as long, I as Long, j as Long

 finalrow = sourcesheet.cells(rows.count, 3).End(xlup).row

 j=6                                 'this is the row my sourcesheet starts data
         for i=6 to finalrow          'this is the row my activesheet starts data[INDENT]        If sourcesheet.cells(i,3)<> "" Then
        Activesheet.Cells(i,3).value = sourcesheet.cells(I,3).value
        j=j+1
End if[/INDENT]
Next I

activesheet.copy

 End Sub
 
Last edited:
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Note that you can get some of the code you need by using the Macro Recorder (just turn on the Macro Recorder, and record yourself performing the steps manually).

You can capture the name of sheet names by using the name property, i.e.
Code:
Dim myName as String
myName = ActiveSheet.Name
See how far you can get with those two tidbits of information, and post back with your new code if you run into problems.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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