set range

atbenline

New Member
Joined
Feb 18, 2018
Messages
8
Hi, I have hit a wall trying to create a macro to set a range using the last column with data and column "C". Column "C" being the constant and the other column always changing.

macrohelp.JPG


Thanks for any help,

Tyler
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Not sure what the point is of applying CF to a column your going to hide, but try
VBA Code:
Sub atbenline()
   Dim UsdCols As Long, UsdRws As Long
   Dim MyRange As Range
   UsdCols = Cells.Find("*", , xlValues, , xlByColumns, xlPrevious, , , False).Column
   UsdRws = Range("C" & Rows.Count).End(xlUp).row
   Set MyRange = Union(Range("C1:C" & UsdRws), Cells(1, UsdCols).Resize(UsdRws))
   With MyRange
      .FormatConditions.Delete
      .FormatConditions.AddUniqueValues
      .FormatConditions(.FormatConditions.Count).SetFirstPriority
      .FormatConditions(1).DupeUnique = xlDuplicate
      With .FormatConditions(1).Font
         .Bold = True
         .Italic = False
         .Color = -16776961
         .TintAndShade = 0
      End With
      With .FormatConditions(1).Interior
         .PatternColorIndex = xlAutomatic
         .Color = 13158625
         .TintAndShade = 0
      End With
      .FormatConditions(1).StopIfTrue = False
   End With
   MyRange.Areas(2).EntireColumn.Hidden = True
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,787
Messages
6,174,561
Members
452,573
Latest member
Cpiet

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