Consulting

Results 1 to 2 of 2

Thread: need help to edit code use values instead of coords

  1. #1
    VBAX Mentor
    Joined
    Feb 2016
    Posts
    382
    Location

    need help to edit code use values instead of coords

    The following code works with Coords for Example: 1-10- but would like to have used on values such as 5678 or 9872 etc.

    Sub blah()
    'USED WITH FOR EXAMPLE  2-2-A    WILL BE PLACED AS 2-2- IN COLUMN AF  THEN RUN THE BLAH    
    Set Destn = Range("AI2:AP71")    
    DVal = Destn.Value    
    Range("AF1").Value = "temp"    
    Set SceData = Range(Range("AF1"), Range("AF1").End(xlDown))    
    SceData.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AE1"), Unique:=True    
    Set Uniques = Range(Range("AE2"), Range("AE1").End(xlDown))    
    For Each cll In Uniques.Cells        
    x = Application.CountIf(SceData, cll.Value)        
    coords = Split(cll.Value, "-")        
    DVal(CLng(coords(1)), CLng(coords(0))) = x    
    Next cll    Range("AE1:AF1").ClearContents    
    Uniques.ClearContents    
    Destn.Value = DVal
    End Sub
    Last edited by Aussiebear; 02-10-2023 at 11:19 PM. Reason: Corrected code tags and layout

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    The name of the sub leads me to think it could be one of mine.
    At first glance, I see no reason it shouldn't work with larger values.
    Where did you get it?
    Also, it would make things easier (and give context) if you could attach a workbook to work on.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •