+ Reply to Thread
Results 1 to 14 of 14

Finding Max Value with a Loop

Hybrid View

  1. #1
    Registered User
    Join Date
    04-22-2013
    Location
    Ankara
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Finding Max Value with a Loop

    Hi Holger,

    I meant I could not run the code you post it;

    Sub DeleteValues()
    Dim wsList As Worksheet
    Dim wsData As Worksheet
    Dim rngFound As Range
    Dim lngCounter As Long
    
    Set wsList = Sheets("Sorted Like That")
    Set wsData = Sheets("View for Sheet-1")
    
    For lngCounter = 1 To 5
      Set rngFound = wsData.UsedRange.Find(what:=wsList.Cells(lngCounter, "A").Value)
      If Not rngFound Is Nothing Then
        rngFound.ClearContents
      End If
    Next lngCounter
    
    Set wsData = Nothing
    Set wsList = Nothing
    End Sub

    I have no experience and knowledge about any coding language. The example file is a small version of my project but I can not progress. And that's the situation.

    Thanks for your interest.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 365 on Win11 (365 on Win11 (desktop), 365 on Win11 (notebook)
    Posts
    8,207

    Re: Finding Max Value with a Loop

    Hi, Oxco,

    the posted code would not have any effect on your sheets as the worksheets mentioned do not exist in the sample.

    Sub EF918635_Post_11_re()
    Dim wsData As Worksheet
    Dim rngFound As Range
    Dim rngSearch As Range
    Dim lngCounter As Long
    
    Set wsData = Sheets("Sayfa1")
    Set rngSearch = wsData.Range("B2:F6")
    
    For lngCounter = 1 To 5
      Set rngFound = rngSearch.Find(what:=WorksheetFunction.Large(rngSearch, lngCounter))
      If Not rngFound Is Nothing Then
        MsgBox "Number " & lngCounter & " found in " & rngFound.Address(0, 0) & vbCrLf & _
            "for Row " & wsData.Cells(rngFound.Row, 1) & " and Column " & wsData.Cells(1, rngFound.Column)
    '    rngFound.ClearContents
      End If
    Next lngCounter
    
    Set rngFound = Nothing
    Set rngSearch = Nothing
    Set wsData = Nothing
    End Sub
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1