LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Macro problem

Using Excel 2000:

I used the macro recorder to design the follwoing macro then I went in with
help from books and modified it to try and attempt what I want it to do. I
want ed to try and repeat a process just using a different file and it
doesn't seem to work. Let me show you the macro and show the part that
doesn't work:

Private Sub CommandButton1_Click()



Dim Controls(20)



Sheets("Population Download").Cells.Clear

Sheets("Demographics Download").Cells.Clear

ChDir "c:\Documents and settings\pete.sitetech03\desktop\Demographic
Downloads"

FileToOpenPop = Application.GetOpenFilename("Excel Files (*.xls),
*.xls")

Workbooks.Open FileToOpenPop

Worksheets(1).Range("A1:J80").Copy

ActiveWorkbook.Close False

Windows("Quick Facts 2004.xlt").Activate

ThisWorkbook.Sheets("population download").Range("A1").PasteSpecial
Paste:=xlPasteAll

Application.CutCopyMode = False

ChDir "c:\Documents and settings\pete.sitetech03\desktop\Demographic
Downloads"

FileToOpenDem = Application.GetOpenFilename("Excel Files (*.xls),
*.xls")

Workbooks.Open FileToOpenDem

Worksheets(1).Range("A1:J80").Copy

ActiveWorkbook.Close False

Windows("Quick Facts 2004.xlt").Activate

ThisWorkbook.Sheets("demographics download").Range("A1").PasteSpecial
Paste:=xlPasteAll

Application.CutCopyMode = False



Up to this point everything works the next section is the first part of
copying and pasting info to another file and this part works



' Gets date from population datasheet

Sheets("population db").Select

ThisWorkbook.Sheets("population db").Range("A2").Select

ThisWorkbook.Sheets("population db").Range("a2:dk2").Select

Selection.Copy

ChDir "c:\Documents and settings\pete.sitetech03\my documents"

Workbooks.Open "c:\Documents and settings\pete.sitetech03\my
documents\populationdb.xls"

Sheets("sheet1").Range("A1").Select

ActiveCell.End(xlDown)(2).Select

Selection.PasteSpecial Paste:=xlValues

Selection.PasteSpecial Paste:=xlFormats

Sheets("sheet1").Range("A1").Select

Workbooks("populationdb.XLS").Close SaveChanges:=True

Application.CutCopyMode = False





This is the section where I want to do the same procedure from the section
above just to a different file. It seems to work up to the line:
ActiveCell.End(xlDown)(2).Select





' Get data from demographic datasheet

Sheets("demographic db").Select

ThisWorkbook.Sheets("demographic db").Range("A2").Select

ThisWorkbook.Sheets("demographic db").Range("a2:bx2").Select

Selection.Copy

ChDir "c:\Documents and settings\pete.sitetech03\my documents"

Workbooks.Open "c:\Documents and settings\pete.sitetech03\my
documents\demographicdb.xls"

Sheets("sheet1").Range("A1").Select

Range("A1").Activate

ActiveCell.End(xlDown)(2).Select

Selection.PasteSpecial Paste:=xlValues

Selection.PasteSpecial Paste:=xlFormats

Sheets("sheet1").Range("A1").Select

Workbooks("demographicdb.XLS").Close SaveChanges:=True

Application.CutCopyMode = False

' ActiveWorkbook.Close False





End Sub



Any help will be appreciated.



Pete Provencher


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with macro Dazed and Confused[_2_] New Users to Excel 2 March 7th 09 11:48 PM
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 Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
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 Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Macro problem [email protected] Excel Discussion (Misc queries) 6 January 2nd 07 09:22 PM
macro problem Kevin Excel Discussion (Misc queries) 1 December 14th 04 10:47 PM


All times are GMT +1. The time now is 08:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"