LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Report Post  
Louisville Cardinals
 
Posts: n/a
Default

THANKS A BUNCH!!!!!! Spreadsheet is doing everything I was hoping it could do.

"Dave Peterson" wrote:

Wkbk.Worksheets("sheet3").Range("o4:o22").Copy _
Destination:=DestCell

Could become:
Wkbk.Worksheets("sheet3").Range("o4:o22").Copy
destcell.pastespecial paste:=xlpastevalues


Louisville Cardinals wrote:

Figured out the macro so previous post can be ignored. How ever my new
problem is that the information that is being copied is the result of a
formula; therefore I get
the #REF! error. I need to just paste the values. What line do I need to
add or edit inorder to just paste the values? Once again thanks for all your
help!!
"Dave Peterson" wrote:

I'd use something like:

Option Explicit
Sub CommandButton1_Click()

Dim myFileName As Variant
Dim Wkbk As Workbook
Dim DestCell As Range

Set ActSheet = activesheet

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

If myFileName = False Then
Exit Sub 'user hit cancel
End If

Set Wkbk = Workbooks.Open(Filename:=myFileName)

With Me
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

Wkbk.Worksheets("sheet3").Range("o4:o22").Copy _
Destination:=DestCell

Wkbk.Close savechanges:=False

End Sub

By opening, copying, then closing, you should be back where you started.

And I'm assuming you used a commandbutton from the control toolbar toolbox.
(The Me keyword refers to the sheet that owns that commandbutton.

DestCell is where the copied range is pasted. I used the first open cell in
column A (working from the bottom up.)

But you could set that destcell to anything you want.

Louisville Cardinals wrote:

Ok. Here is a new twist. I need to be able to copy the info from the daily
spreadsheets into the spreadsheet that activated the macro. I have the
following code so far but I am stuck. When I click on the command button I
am prompted for the file to pull the information out of but I need to switch
back to the file with the command button and paste the info that was copied.

NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls),
*.xls", Title:="Please select a file")
If NewFN = False Then
' They pressed Cancel
MsgBox "Stopping because you did not select a file"
Exit Sub
Else
Workbooks.Open Filename:=NewFN
Worksheets("sheet3").Range("O4:O22").COPY

End If
End Sub

Thanks for your help....... again

--

Dave Peterson


--

Dave Peterson

 
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
how to enable macro ginger Excel Worksheet Functions 2 April 11th 05 08:36 PM
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro Formula revision? Mark Excel Worksheet Functions 1 November 28th 04 01:43 AM


All times are GMT +1. The time now is 03:37 PM.

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

About Us

"It's about Microsoft Excel"