+ Reply to Thread
Results 1 to 2 of 2

changing file names with macros

  1. #1
    Registered User
    Join Date
    12-09-2005
    Posts
    1

    changing file names with macros

    Can anyone help me with this code

    What i'm trying to do is get the last 3 letter of the file name ie AWE to be replaced with
    what is in a selected cell. In this case A32
    please help

    Sub update()

    Range("A32").Select
    franking = ActiveCell.FormulaR1C1

    'ActiveCell.FormulaR1C1 = _
    "='[Reuters Contribution fields_AWE.xls]Estimates'!R29C2"

    End Sub

  2. #2
    Dave Peterson
    Guest

    Re: changing file names with macros

    Maybe you could look for .xls] and back off from there?

    Option Explicit

    Sub update()
    Dim Franking As String
    Dim NewFranking As String
    Dim NewText As String
    Dim DotXLSPos As Long

    Franking = Range("a32").FormulaR1C1
    NewText = Range("a1").Value

    ''' Franking = "='[Reuters Contribution fields_AWE.xls]Estimates'!R29C2"

    DotXLSPos = InStr(1, Franking, ".xls]", vbTextCompare)

    If DotXLSPos = 0 Then
    MsgBox "not found"
    Else
    NewFranking = Left(Franking, DotXLSPos - 5 + 1) _
    & NewText & Mid(Franking, DotXLSPos)
    MsgBox NewFranking
    End If

    End Sub

    An alternative...

    You may want to record a macro when you change links
    edit|links
    and use that technique instead.

    "trevor@OML" wrote:
    >
    > Can anyone help me with this code
    >
    > What i'm trying to do is get the last 3 letter of the file name ie AWE
    > to be replaced with
    > what is in a selected cell. In this case A32
    > please help
    >
    > Sub update()
    >
    > Range("A32").Select
    > franking = ActiveCell.FormulaR1C1
    >
    > 'ActiveCell.FormulaR1C1 = _
    > "='[Reuters Contribution fields_AWE.xls]Estimates'!R29C2"
    >
    > End Sub
    >
    > --
    > trevor@OML
    > ------------------------------------------------------------------------
    > trevor@OML's Profile: http://www.excelforum.com/member.php...o&userid=29503
    > View this thread: http://www.excelforum.com/showthread...hreadid=492083


    --

    Dave Peterson

+ Reply to Thread

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