Results 1 to 6 of 6

Thread: How to find particular column name by using Excel Macro

  1. #1
    Join Date
    Mar 2011
    Posts
    71

    How to find particular column name by using Excel Macro

    Hello yesterday I faced one problem with my Excel. I have Excel shit which contains column names in row#1. Basically I am facing problem with excel macro. I want to write excel macro that will appear for column names no matter which that had 'ID' or 'AMT' in it, and be supposed to format complete column apart from 1st row which has name in 0000-000-00 for ID and $ 000,000,00.00 for AMT. So that time devoted in formatting every column will be concentrated. I would really appreciate if somebody be acquainted with solution about it. Thanks in advance.

  2. #2
    Join Date
    Jun 2009
    Posts
    1,518

    Re: How to find particular column name by using Excel Macro

    Hello please follow this macro I hope this will help you to solve your problem. Because some day before I was facing similar kind of problem them I follow this macro and by using this I solve my problem.
    Sub tesmacr()
    Dim i As Integer, cfindmacro As Range
    Set cfindmacro = ActiveSheet.UsedRange.Cells.Find(what:="ID", lookat:=xlWhole)
    i = cfind.Column
    Columns(i).NumberFormat = "000-000-000"
    Set cfindmacro = ActiveSheet.UsedRange.Cells.Find(what:="AMT", lookat:=xlWhole)
    i = cfindmacro.Column
    Columns(i).NumberFormat = "000,000,00#.00"
    End Sub
    I hope it will work for you.

  3. #3
    Join Date
    Mar 2011
    Posts
    71

    Re: How to find particular column name by using Excel Macro

    Hi, thank you for your quick response on my query. I try this code and its working fine with excel. But in my case basically column is not always ID; it can be ID1, 1_ID, ID_1. So I require searching columns with key like ID and then format. And in another case, in addition ID column will forever have alphanumeric values similar to 123CD6789 and I wish for it as 123-CD6-789.NumberFormat doesn't perform on behalf of alphanumeric.

  4. #4
    Join Date
    Mar 2011
    Posts
    77

    Re: How to find particular column name by using Excel Macro

    Hello guys I am facing similar kind of problem related to this macro. I am using Microsoft office 2007 in my system. And I am doing all my office work on this Excel. So this Excel is more important in my work. I donít understand how to fix this ID related issues. I try to find about this on internet but not get much information on this topic. How I can write macro with any ID. Because, ID is not a big factor still itís not performing. Some day before, I read seaware about the wild card in macro. Is it possible to use them with this? Can anyone tell me how you can use wildcard for searching? Help me thank you.

  5. #5
    Join Date
    Nov 2008
    Posts
    1,514

    Re: How to find particular column name by using Excel Macro

    Hello follow the following code by using this you can set wildcard with macro for your code. You have to use
    what: = like this
    what: ="*id*

    and observe whether you achieve something. Basically when you are using star sign before and after is known as wildcard in the company of the ID in between. By using wild card some items achieve something and some time itís not performing as your requirement. So I hope this will work for your thank you.

  6. #6
    Join Date
    Mar 2009
    Posts
    1,360

    Re: How to find particular column name by using Excel Macro

    When responsibility searches in Excel, you can make use of wildcard characters in the pattern of what you are trying to search with Excel. On the other hand, you cannot make use of them in the alternate text. These tips look at ways you are able to work around this limitation and utilize wildcards in your replacements. This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007. I hope now you are clear with your doubt about this wildcard processing with macro in Excel.

Similar Threads

  1. Excel macro: Cells.Find finding value from a variable?
    By pkpn in forum Software Development
    Replies: 2
    Last Post: 14-05-2011, 03:31 PM
  2. Find The Value of one column in another column
    By Charth in forum Windows Software
    Replies: 3
    Last Post: 23-02-2011, 02:01 AM
  3. Excel Macro querying a table by column name
    By Halyn in forum Software Development
    Replies: 3
    Last Post: 14-10-2009, 08:59 PM
  4. Cannot find macro working in excel 2007
    By Visala in forum Windows Software
    Replies: 3
    Last Post: 06-08-2009, 11:47 PM
  5. Replies: 3
    Last Post: 01-07-2009, 03:04 PM

Posting Permissions

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