+ Reply to Thread
Results 1 to 2 of 2

Select a cell based on column and Row search

Hybrid View

  1. #1
    Registered User
    Join Date
    03-12-2023
    Location
    Syd Aus
    MS-Off Ver
    365
    Posts
    5

    Select a cell based on column and Row search

    Hi All,

    Need a hand finding the correct way to get this vba code to work

    I'm not using tables for a variety of reason.

    I want to select a Person and a type of fruit on Sheet 2
    If that person has that fruit listed, It should be removed from their Row.


    Im trying to select the row based on (Name) on Sheet1
    Then i want to search that row for the fruit name based on Sheet2 (Fruit)
    Then clear the cell.


    Ive already set the variables

    Bit stuck with my very limited vba knowledge.

    Thanks guys

    Dan

    
    Dim Frng As Range, Qty$, Fruit$, Names$
    With Sheets("Sheet2")
    Qty = 1: Fruit = .Range("D14"): Names = .Range("C14")
    
    Set Frng = Sheets("sheet1").Range("B:B").Find(Name)
     Row Frng.Select
     Range("Frng:Frng").Find (Fruit)
     If Not Frng Is Nothing Then
     Selection.ClearContents
     End If
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,747

    Re: Select a cell based on column and Row search

    No error checking but this works:

    Option Explicit
    
    Sub Test()
    
    Dim Frng As Range, Qty$, Fruit$, Name$
    With Sheets("Sheet2")
        Qty = 1: Fruit = .Range("D14"): Name = .Range("C14")
        
        Set Frng = Sheets("sheet1").Range("B:B").Find(Name)
        Set Frng = Frng.Resize(, 8).Find(Fruit)
        If Not Frng Is Nothing Then
            Frng.ClearContents
        End If
    End With
    
    End Sub
    First problem was Dimming Names$ and then trying to find Name. Use Option Explicit. Then some Range references were wrong.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] select entire column based on activecell - multiply cells based if found empty cell
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-08-2016, 01:52 AM
  2. How do I select a row based on a search in a column?
    By VanillaHaze in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-19-2015, 07:00 PM
  3. Select cell based on the last entry in other column
    By Kehjz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2013, 02:44 PM
  4. [SOLVED] Select all data in a column based on search return
    By rtcwlomax in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 09:47 AM
  5. select column based on cell input
    By jcfrancisco in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-04-2011, 09:52 AM
  6. Search column and select the cell
    By justinng in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-15-2009, 09:57 PM
  7. Select a column based on a cell entry
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-29-2005, 08:05 AM

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