+ Reply to Thread
Results 1 to 4 of 4

Help!!! Find column and define with name

  1. #1
    Registered User
    Join Date
    06-01-2015
    Location
    Austin, Texas
    MS-Off Ver
    MS Excel 2013
    Posts
    3

    Help!!! Find column and define with name

    I have a problem with my code. First off I am new to coding. Researched different sites online and the code I wrote is the best I came up with.
    What I am trying to do with my code is search for the column name in Row 1 of each column (A1, B1, C1, ect..). After it finds the first two or three characters of the name of the column. Select that column and define that column by the name I supplied. So I can use that new define name in a formula I created. The problem that I have is I have two column with similar names and it always define the one that I do not want. One column is (B1) "KbTVD" the one I dont want defined and (F1) "TVD" the one I need. Every time I run my code it selects and defines B1 and I need F1 to be defined instead. Also I need my code to search different row 1 columns just for "TVD" because it is not a guarantee that "TVD" will always be in F1.

    Code:

    Please Login or Register  to view this content.
    this code selects and defines B1

    Please Login or Register  to view this content.
    I tried to rewrite it and I get a error

    run-time error '91':

    object variable or with block variable not set


    Also do I need to Dim something in my code?

  2. #2
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Help!!! Find column and define with name

    PHP Code: 
    Option Explicit
    Sub DATA
    ()
     
    Dim fNd As RangesRng As Range
     
        Set fNd 
    Range("1:1").Find("on", , xlFormulasxlPart)
        If 
    fNd Is Nothing Then
            MsgBox 
    "Nothing"
        
    Else
            
    ActiveWorkbook.Names.Add "ono"fNd.EntireColumnTrue
        End 
    If
        
    '    Set fNd = Range("1:1").Find("tvd")'
    '    ActiveWorkbook.Names.Add "tvd", fNd.EntireColumn, True '
    End Sub 

  3. #3
    Registered User
    Join Date
    06-01-2015
    Location
    Austin, Texas
    MS-Off Ver
    MS Excel 2013
    Posts
    3

    Re: Help!!! Find column and define with name

    Sa DQ thax for the reply, but I looking for "TVD" in (F1) to be found and changed. It keeps selecting "KBTVD" in (B1) instead. Will that code get the exact match for the string in (F1)?

  4. #4
    Registered User
    Join Date
    06-01-2015
    Location
    Austin, Texas
    MS-Off Ver
    MS Excel 2013
    Posts
    3

    Re: Help!!! Find column and define with name

    bump bump bump

+ 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. Can't find a way to define variables
    By Mole in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2011, 02:42 PM
  2. How can I find items that have a certain prefix and define?
    By brantty in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  3. How can I find items that have a certain prefix and define?
    By Roger Govier in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 11:05 AM
  4. How can I find items that have a certain prefix and define?
    By Roger Govier in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 06:05 AM
  5. How can I find items that have a certain prefix and define?
    By brantty in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12: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