You need to store the column numbers to use them. Declare them first:
Dim col As Object
Dim intCol1 As Integer
Dim intCol2 As Integer
Use this to get the variables
For Each col In Range("D_columns").Columns
If col.EntireColumn.Hidden = False Then
If intCol1 = 0 Then
intCol1 = col.Column
Else
intCol2 = col.Column
End If
End If
Next
If you need to pass the variables to Hide_Count_Columns, do it like this:
Call Hide_Count_Columns(intCol1, intCol2)
Then you would declare the sub Hide_Count_Columns like this:
Sub Hide_Count_Columns(ByVal intCol1 As Integer, ByVal intCol2 As Integer)
'do something with column numbers
End Sub
Or if you do want to put the column numbers on the worksheet, you would create range names for them intCol1
and intCol1
Then put the column numbers there like this:
ActiveSheet.Range("intCol1").Value = intCol1
ActiveSheet.Range("intCol2").Value = intCol2