vendredi 6 février 2015

Excel count target then output value in cell


Vote count:

0




Things got pretty desperate for me that I actually created an account to ask my question.


I have a workbook with three sheets (Dash, HT, RV.) I am trying to write a macro/function that counts how many times a value from 'Dash' exists in a specific column within sheet 'RV' then output that value in a specific cell within 'Dash'


I could go so far as to say that the value within 'Dash' is static and repeat it (The variable from 'Dash' won't ever change as it's a list of Usernames)


In my head it's something like: Count whatever.variable.Dash in column J of sheet.RV print in Dash.B2...


I was able to find a MsgBox option that works, but I have to manually type in each Username (which is a 16character name (string)) then a MsgBox tells me the occurrences. I'm looking to just automate this option with a fixed/static username in the macro/function because the amount of rows in 'RV' can vary between 700 entries to 23k entries


The MsgBox option is:



Dim Count as Integer
Dim Target As String
Dim Cell as Object
Dim N As Integer

Sub Target_Count()
Count = 0
Target = InputBox("character(s) to find?")
If Target = "" Then GoTo Done
For Each Cell in Selection
N = InStr(1, cell.Value, target)
While N <> 0
Count = count + 1
N = InStr(n + 1, cell.Value, target)
Wend
Next Cell
MsgBox count & " Occurrences of " & target
Done:
End Sub


I want the input box target to be 'Dash.A1:8' and the occurrences to be printed in 'Dash.B1:8'


Sorry if my explanation is confusing, my head is just mush trying to figure out the last piece of my puzzle.



asked 3 mins ago

Rob

1






Excel count target then output value in cell

Aucun commentaire:

Enregistrer un commentaire