Results 1 to 3 of 3

To Find and Insert column and add Formula and copy formula down

Threaded View

  1. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: To Find and Insert column and add Formula and copy formula down

    Hi,

    After testing the code in the workbook you provided, I saw that the raw data header "Material description" had trailing spaces, why you can use the find function xlpart instead of xlwhole. In addition, the numberformatting of the raw data cells needs reformatting for formulas to work.

    I did also tweak your code a little bit as I rewrote it:
    Sub Insrt_MatType2()
    
        Dim rngFind As Range
    
        With Sheets("Raw Data")
            Set rngFind = .Rows(1).Find("Material description", , xlValues, xlPart)
            If Not rngFind Is Nothing Then
                rngFind(1, 2).EntireColumn.Insert
                rngFind(1, 2).Value = "Material type"
                With .Range(rngFind(2, 2), .Cells(Rows.Count, rngFind.Column).End(xlUp)(1, 2))
                    .NumberFormat = 0
                    .Formula = "=IF(ISNUMBER(FIND(""S"",A2)),""Sample"",IF(ISNUMBER(FIND(""Z"",A2)),""Sample"",IF(ISNUMBER(FIND(""T"",A2)),""Tester"",IF(ISNUMBER(FIND(""Y"",A2)),""Tester"",""FG""))))"
                End With
                Set rngFind = Nothing
            End If
        End With
    
    End Sub
    Hope it works.

    Cheers,
    berlan
    Last edited by berlan; 07-27-2014 at 09:34 PM. Reason: EDIT after testing the workbook provided

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA macro to add header text, insert & copy-down formula, move column
    By shootstill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2014, 05:44 AM
  2. Vba - find next empty column, insert column, copy paste values & copy paste formulas
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:43 PM
  3. [SOLVED] Formula to find header and insert in new column
    By dbracken1 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-03-2012, 03:50 AM
  4. Macro to insert formula and copy down column
    By robertguy in forum Excel General
    Replies: 4
    Last Post: 03-01-2012, 12:03 PM
  5. find value, insert row,copy formula, enter data
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2010, 11:39 PM

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