Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error in Macro
I'm trying to create a macro that will copy data from one sheet to another.
It should bring up a InputBox where you would input the name of the workbook, find it within the specified directory and paste the data to that workbook, but I'm getting some errors within it, my code can be seen below: Sub CopyData() Dim rngCopyFrom As Range Dim wbkCopyTo As Workbook Dim rngCopyTo As Range Dim inpData As Integer inpData = InputBox(Prompt:="Enter Market Name", _ Title:="Market Name", Default:="Enter Market Name here") If inpData = "Enter Market Name here" Or _ inpData = vbNullString Then Exit Sub Else On Error Resume Next Set wbkCopyTo = Workbooks(inpData) If wbkCopyTo Is Nothing Then Set wbkCopyTo = Workbooks.Open("C:\Documents and Settings\jermaine_wanyou\Desktop\FACTBOOK SYSTEM\New Folder\") On Error GoTo 0 If wbkCopyTo Is Nothing Then MsgBox "Sorry... Can't find the destination file." Else Set rngCopyFrom = ThisWorkbook.Sheets("Sheet1").Range("B4:M17") Set rngCopyTo = wbkCopyTo.Sheets("Sheet1").Range("B4:M17") End If End If End If rngCopyTo.Value = rngCopyFrom.Value wbkCopyTo.Close End Sub I'm very lost here, I'm not sure where exactly the error is coming from but much help will be appreciated |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Worksheet Functions | |||
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable | Excel Discussion (Misc queries) | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
naming tab macro error runtime error 1004 | Excel Programming | |||
Macro 'Automation error' with ChemOffice Excel macro | Excel Programming |