VBA Hey guys, I just started to work with VBA and i am looking for a solution to my problem. The task is to count the number of different Values (Suppliers) inside a column, starting at a fixed point, lets say for column A to start at A5, but end at the last value in that column. Every time i try to put the range from A5 to last written cell in column A I either get errors or a wrong answer. Anyone here that can help me out?
Sub Count_Values_()
Sheets("Präsentation").Select
Dim dblAnz As Double
Dim rngRange As Range, rngRangeCnt As Range
Set rngRange = Range("A5:A50")
For Each rngRangeCnt In rngRange
dblAnz = dblAnz + 1 / WorksheetFunction.CountIf(rngRange, rngRangeCnt.Text)
Next
Dim Bereich As Range
Dim Zelle As Range
Dim lAnzahl As Long
Set Bereich = Range("A5:A50")
For Each Zelle In Bereich
If Zelle.Font.Bold = True Then
lAnzahl = lAnzahl + 1
End If
Next Zelle
Sheets("Anleitung").Select
Range("F1").Value = dblAnz - lAnzahl - 1
End Sub
This is the code I used before by searching values from A5 to A50 and subtracting all the bold headlines. I also added a -1 as an empty cell counts as a value as well I guess or at least I got the right numbers this way.