Results 1 to 4 of 4

VBA code affecting header unintentionally

Threaded View

  1. #1
    Registered User
    Join Date
    07-14-2011
    Location
    Cocoa Beach, Florida
    MS-Off Ver
    Excel 2007
    Posts
    79

    VBA code affecting header unintentionally

    So, I figured out how to add a defined text string to the end of the values in my cells, but now I have run into another issue.

    I took a piece of code that I found from someone else with another question and I modified it (as best I could with my limited experience) to fit what I needed.

    Long story short:

    I am copying info from one excel workbook to a new workbook, each column has been changed so that they are in different orders. In column "E" in my new workbook I am adding the file extension ".pdf" to the end of the values that were copied over. The code I have thus far looks like :


    
    Dim Myrange As Range, Mystr As String
        Application.ScreenUpdating = False
         
        Mystr = ".pdf"
         
         'If there are no constants then an error will be raised.
        On Error Resume Next
        Set Myrange = Intersect(ActiveSheet.Range("E:E"), ActiveSheet.Cells.SpecialCells(xlConstants))
        On Error GoTo 0
         
         'If there are no constants in Column A then exit
        If Myrange Is Nothing Then Exit Sub
         
        With Myrange
            .Offset(0, 1).Columns.Insert
            .Offset(0, 1).FormulaR1C1 = "=Concatenate(RC[-1], """ & Mystr & """)"
            .Columns(1).EntireColumn.Formula = .Columns(1).Offset(0, 1).EntireColumn.Value
            .Columns(1).Offset(0, 1).EntireColumn.Delete
        End With
         
        Application.ScreenUpdating = True

    but the issue I have is that it is modifying my header "E1" to say "Document File Name.pdf" instead of leaving it as "Document File Name". I thought I would just get around my limited experience by having the macro alter the entire column, then tell it to change the value in E1 with

    
    [E1].Value = "Document File Name"
    right after the addition of the ".pdf" takes place. For some reason my coding runs through fine, no errors occur but I still end up with ".pdf" at the end of my header title, how can I get rid of this?


    Sorry for all the questions but my work through me on this and I have no clue as to how to do it, neither do they but they want me to figure it out lol.
    Last edited by sk8shorty01; 07-18-2011 at 12:39 PM.

Thread Information

Users Browsing this Thread

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

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