View Single Post
 
Old 10-29-2015, 12:43 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by PRA007 View Post
Actually I wanted to automate few things using vbscript.
...
This code further runs macro solution given by you above.
You hadn't previously mentioned wanting to automate in this way. Even so, that code won't run the macro I posted, since it tries to use a workbook named 'Fees.xlsm' and your attachment workbooks were named 'Main.xlsx' and 'Database2.xlsx'.

Furthermore, in post #7 you have:
Code:
Set wkb = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\Sheet1.xlsx")
Set wkb1 = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\FE.xlsx")
Set xlShtTgt = Workbooks("Sheet1.xlsx").Sheets(1)
Set xlShtSrc = Workbooks("FE.xlsx").Sheets(1)
Aside from the fact that could could be reduced to:
Code:
Set wkb = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\Sheet1.xlsx")
Set wkb1 = Workbooks.Open("C:\Users\rahulkumar.patel\Desktop\FE.xlsx")
Set xlShtTgt = wkb .Sheets(1)
Set xlShtSrc = wkb 1.Sheets(1)
this code doesn't do any of the checking to see if either workbook is already open. As I said in post #8, I've already given you code showing how to do that. If you don't do such checks, you risk having your macro crash.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote