Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default this should work..

But it doesn't make the copy !!..
what's the problem??

----------------------------------------------
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A18").Value =
("Shee t1").Cells("D40").Value
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default this should work..

Is the other workbook open? If not,

Try adding something like this (untested)

on error resume next
Dim oWB as workbook
Dim oWS as worksheet

Set oWB = Workbooks(WorkbookName) 'this is something like ABC.xlsm
on error goto 0

if owb is nothing then
Set oWB = workbooks.open(FullWorkbookPath) 'C:\WB\ABC.xlsm'
end if

if not owb is nothing then
MsgBox("No workbook was opened")
Exit sub
end if

Set oWS = owb.sheets("Sheet1")
if not ows is nothing then
aws.range("A18").value = OWB.Sheets("Sheet1").Cells("D40").value
end if
end if

owb.close


--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"pls123" wrote:

But it doesn't make the copy !!..
what's the problem??

----------------------------------------------
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A18").Value =
("Shee t1").Cells("D40").Value

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default this should work..

ty barb i will work on it in the weekend :)


"Barb Reinhardt" wrote:

Is the other workbook open? If not,

Try adding something like this (untested)

on error resume next
Dim oWB as workbook
Dim oWS as worksheet

Set oWB = Workbooks(WorkbookName) 'this is something like ABC.xlsm
on error goto 0

if owb is nothing then
Set oWB = workbooks.open(FullWorkbookPath) 'C:\WB\ABC.xlsm'
end if

if not owb is nothing then
MsgBox("No workbook was opened")
Exit sub
end if

Set oWS = owb.sheets("Sheet1")
if not ows is nothing then
aws.range("A18").value = OWB.Sheets("Sheet1").Cells("D40").value
end if
end if

owb.close


--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"pls123" wrote:

But it doesn't make the copy !!..
what's the problem??

----------------------------------------------
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A18").Value =
("Shee t1").Cells("D40").Value

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default this should work..

but.......the other workbook is open !!



"Barb Reinhardt" wrote:

Is the other workbook open? If not,

Try adding something like this (untested)

on error resume next
Dim oWB as workbook
Dim oWS as worksheet

Set oWB = Workbooks(WorkbookName) 'this is something like ABC.xlsm
on error goto 0

if owb is nothing then
Set oWB = workbooks.open(FullWorkbookPath) 'C:\WB\ABC.xlsm'
end if

if not owb is nothing then
MsgBox("No workbook was opened")
Exit sub
end if

Set oWS = owb.sheets("Sheet1")
if not ows is nothing then
aws.range("A18").value = OWB.Sheets("Sheet1").Cells("D40").value
end if
end if

owb.close


--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"pls123" wrote:

But it doesn't make the copy !!..
what's the problem??

----------------------------------------------
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A18").Value =
("Shee t1").Cells("D40").Value

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default this should work..

The source workbook needs to be open. Moreover, when you reference
another (open) workbook, you use only the file name (e.g. "ABC.xls")
not the complete path to the workbook (e.g., "C:\Test\ABC.xls").

aWS.Range("A18").Value = _
Workbooks("ABC.xls").Sheets("Sheet1").Range("D40") .Value

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 13 Dec 2008 04:50:05 -0800, pls123
wrote:

But it doesn't make the copy !!..
what's the problem??

----------------------------------------------
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A18").Value =
("She et1").Cells("D40").Value



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default this should work..


now its ok.. !!
i was looking for the "workbooks.sheets.range" trick by longtime..
ty everybody


"Chip Pearson" wrote:

The source workbook needs to be open. Moreover, when you reference
another (open) workbook, you use only the file name (e.g. "ABC.xls")
not the complete path to the workbook (e.g., "C:\Test\ABC.xls").

aWS.Range("A18").Value = _
Workbooks("ABC.xls").Sheets("Sheet1").Range("D40") .Value

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 13 Dec 2008 04:50:05 -0800, pls123
wrote:

But it doesn't make the copy !!..
what's the problem??

----------------------------------------------
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Sheet1")

aWS.Range("A18").Value =
("She et1").Cells("D40").Value


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
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
how can i automatically generate work order numbers from work orde rob h Excel Discussion (Misc queries) 1 July 13th 09 07:59 PM
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
HOW TO MAKE A LIST OF WORK SHEET IN WORK BOOK IN EXCEL 2007 goutam Excel Programming 1 February 1st 08 07:40 AM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM


All times are GMT +1. The time now is 01:53 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"