Need A Shorter Code

charllie

Well-known Member
Joined
Apr 6, 2005
Messages
986
Hi Folks,

Anyone out there have time to write me a short code for the following please.

I want to search column B in worksheet1 starting from row 6 downwards and for every cell that is > "" i want to copy them and place them in column B of worksheet2 starting from row 6 and continue downwards.

I know how to do it like this for each cell:

If Sheets1.Range ("B6").value >"" then
sheets2.Range ("B6").value = Sheets1.Range ("B6").value
End If

But not sure how to do it short code


Thanks
 

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.
Assuming the blank cells are truly blank (that is, not just displaying as blank due to a formula result), how about this?

Code:
Sub test()
Dim myRng As Range

With Sheets("Sheet1")
    Set myRng = .Range("B6", .Range("B65536").End(xlUp))
End With

With myRng
    .SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
    .SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Sheet2").Range("B6")
    .Rows.Hidden = False
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,635
Messages
6,120,660
Members
448,975
Latest member
sweeberry

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