VBA Unique value Copy/Paste - Making it exclude blanks

EdwardSurrey

New Member
Joined
May 13, 2015
Messages
36
Office Version
  1. 365
Platform
  1. Windows
Hello

I have the following VBA code which moves unique values from a range to another worksheet.

The only issue is that does not exclude blanks - so it always copies one. Is there any modification I can make to skip the blanks?

Sub GetUniques()
Dim d As Object, c As Variant, i As Long, lr As Long
Set d = CreateObject("Scripting.Dictionary")
lr = Cells(Rows.Count, 1).End(xlUp).Row
c = Worksheets("Tracker (2022)").Range("B7:B893" & lr)
For i = 1 To UBound(c, 1)
d(c(i, 1)) = 1
Next i
Worksheets("Win Loss Report").Range("B16").Resize(d.Count) = Application.Transpose(d.keys)
End Sub


Thanks! :)
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try it like
VBA Code:
lr = Worksheets("Tracker (2022)").Cells(Rows.Count, 1).End(xlUp).Row
c = Worksheets("Tracker (2022)").Range("B7:B" & lr)
 
Upvote 0
Solution
Try it like
VBA Code:
lr = Worksheets("Tracker (2022)").Cells(Rows.Count, 1).End(xlUp).Row
c = Worksheets("Tracker (2022)").Range("B7:B" & lr)

Thanks but this isn't working. Cell B25 is the first blank in the tracker sheet, and it's copying that to the Win Loss Report tab.
 
Upvote 0
Are you sure it's totally empty?
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,164
Members
452,615
Latest member
bogeys2birdies

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