Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default assign sheet for embedded macro to run in

Jacob - Absolutely beautiful. I added some msgbox's for user instructions on
what files to select and it's perfect.

Thanks so much.

Anders

"Jacob Skaria" wrote:

Hi Anders

Modified the copy procedure to suit your requirement. Instead of the
destination sheet the destination range is passed as an argument so that you
can reuse..

Sub GetData44()
Dim ws As Worksheet, strFile As String
Dim wb1 As Workbook, wb2 As Workbook

Set wb1 = Workbooks.Add
Set ws = wb1.ActiveSheet
ws.Name = "Milestone Exceptions"

strFile = Application.GetOpenFilename
Set wb2 = Workbooks.Open(strFile)
Call Copy_Milestones(wb2, ws.Range("A1"))

strFile = Application.GetOpenFilename
Set wb2 = Workbooks.Open(strFile)
Call Copy_Milestones(wb2, ws.Range("K1"))

End Sub

Sub Copy_Milestones(wbBook As Workbook, rngTemp As Range)
wbBook.ActiveSheet.Range("A82:j119,A193:j230,A304: J341," & _
"A415:J452,A526:J563,A637:J674,A748:J785,A859:J896 ,A970:J1007," & _
"A1081:J1118,A1192:J1229,A1303:J1340,A1411:J1451,A 1525:J1562").Copy _
rngTemp
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Anders" wrote:

Jacob - very nice!

Follow up - my next step is to open another file open box, select another
file, run the "copy milestones" to select the same and paste in the
previously created workbook starting in cell k1. End goal is to compare the
two side by side. I tried replicating your code, but couldn't get it to
paste into the proper sheet. I think I need to replicate the copy_milestones
code - change the paste destination cell...then..activate the original sheet
but I couldn't get it. thoughts?

Once it's on the sheet - that's my other post on hiding the rows.

Huge thanks..

Anders

"Jacob Skaria" wrote:

Hi Anders

Modified your macro a bit. Try the below and feedback. You can combine the
procedures...

Sub GetData44()
Dim ws As Worksheet, strFile As String
Dim wb1 As Workbook, wb2 As Workbook

Set wb1 = Workbooks.Add
Set ws = wb1.ActiveSheet
ws.Name = "Milestone Exceptions"

strFile = Application.GetOpenFilename
Set wb2 = Workbooks.Open(strFile)
Call Copy_Milestones(wb2, ws)
End Sub

Sub Copy_Milestones(wbBook As Workbook, ws As Worksheet)
wbBook.ActiveSheet.Range("A82:j119,A193:j230,A304: J341," & _
"A415:J452,A526:J563,A637:J674,A748:J785,A859:J896 ,A970:J1007," & _
"A1081:J1118,A1192:J1229,A1303:J1340,A1411:J1451,A 1525:J1562").Copy _
ws.Range("A1")
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Anders" wrote:

Hi All,

I'm having trouble with the following macro. I need to get the "copy
milestones" to run in the file I open and paste into the worksheet I created.
Currently, the macro is copying from the newly created workbook. The sheet
I open will always have a different name so I can't refer to it by sheetname.
How do I make the embedded macro run on the file I select to open?

TIA,
Anders

Sub GetData44()
Set NewBook = Workbooks.Add
With NewBook
ActiveSheet.Name = "Milestone Exceptions"
End With
Set bswks = ActiveSheet
Dim str As String
str = Application.GetOpenFilename
Application.Run ("Copy_Milestones2")
bswks.Activate
Range("a1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

The "Copy Milestones" it refers to is the following:

Sub Copy_Milestones()
Range("A82:j119,A193:j230,A304:J341,A415:J452,A526 :J563,A637:J674,A748:J785,A859:J896,A970:J1007,A10 81:J1118,A1192:J1229,A1303:J1340,A1411:J1451,A1525 :J1562").Copy
End Sub

Reply
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
Assign Macro with Hidden Sheet Pran Excel Worksheet Functions 5 August 4th 09 01:32 PM
Using a Macro in Excel to send an embedded sheet via Outlook Bill Leffler Excel Discussion (Misc queries) 3 July 23rd 08 10:47 PM
Generate sheet names from list, assign data to summary sheet. [email protected][_2_] Excel Programming 4 June 20th 07 09:17 PM
Links in Embedded doc within sheet don't change when sheet is copi Dan k Excel Discussion (Misc queries) 0 May 11th 06 05:41 PM
Assign values to a cell in sheet A, from worksheet_change event of sheet B Arif Khan Excel Programming 1 May 4th 04 04:51 AM


All times are GMT +1. The time now is 06:30 AM.

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"