+ Reply to Thread
Results 1 to 2 of 2

Cant change the pathname on macro to different workbook .

Hybrid View

  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    Fairmont,WV
    MS-Off Ver
    Excel 2007
    Posts
    66

    Lightbulb Cant change the pathname on macro to different workbook .

    I'll make it simple....seems no one can crack this or it just cant be done I guess.
    Here is a code for moving data from Sheet1(Timesheet) to Sheet2(WorkCompCore) same workbook.
    I want to do the exact same thing as this code except put it in Sheet2(WorkCompCore) in a COPY of the workbook. This copy is in the same path as the opened workbook. It is the exact same as the workbook open workbook.Only the name is ALL-N-1-Trial.
    
    
    
    Sub UpdateLogWorksheet()
    
        Dim historyWks As Worksheet
        Dim inputWks As Workbooks
    
        Dim nextRow As Long
        Dim oCol As Long
    
        Dim myRng As Range
        Dim myCopy As String
        Dim myCell As Range
        
       
        myCopy = "H11,A61,A12,B61,B7,H9,B61,C61,D61,H12,E61,F61,G61,H13,H61,I61,J61,A49,A50,A51,A52,A53,A54,A55,A56,A57,A58,H49,H50,H51,H52,H53,H54,H55,H56,H57,H58"
    
        Set inputWks = Worksheets("Timesheet")
        Set historyWks = Worksheets("WorkCompCore")
    
        With historyWks
            nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
        End With
    
        With inputWks
            Set myRng = .Range(myCopy)
    
    
        End With
    
        With historyWks
            
            
            oCol = 1
            For Each myCell In myRng.Cells
                historyWks.Cells(nextRow, oCol).Value = myCell.Value
                oCol = oCol + 1
            Next myCell
        End With
        
        'clear input cells that contain constants
        With inputWks
          On Error Resume Next
             
          On Error GoTo 0
        End With
    
    End Sub
    Seems like a simple thing to do but I cant do it. Ill keep trying ntil a Guru cracks it.
    Last edited by kwik98; 06-10-2010 at 08:27 PM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Cant change the pathname on macro to different workbook .

    Hi kwik98,
    This question has many fine solutions in the forum. Do a search and you'll find the answer.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ 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