I am encountering this error When I use "Let SRange = "C"...." instead, it works but I don't want to specify the end of column like I did as "NV". I'd rater want to use the column in FinalCol. It might be easier to look at the code. I made some changes.. but now it is asking "Object variable or With block variable not set"
Option Explicit
Sub Range_End()
Dim X As Variant, Count, FinalCol, SRange, XRange As Range
Sheets("Formatted").Select
X = InputBox("enter row number")
Count = 1
Do While Cells(4, Count) <> Empty
Count = Count + 1
Loop
FinalCol = Count - 1
' Let SRange = "C" & X & ":" & "NV" & X
SRange = Range(Cells(X, 3), Cells(X, FinalCol)).Address
Application.ScreenUpdating = False
For Each XRange In Range(SRange)
If XRange.Value = "" Then
XRange.EntireColumn.Hidden = True
Else
XRange.EntireColumn.Hidden = False
End If
Next XRange
Application.ScreenUpdating = True
End Sub