Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-09-2012, 04:08 PM
macropod's Avatar
macropod macropod is offline Range(Cell1,Cell2) Error on another workbook controlling some other workbook? Windows 7 64bit Range(Cell1,Cell2) Error on another workbook controlling some other workbook? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,513
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

Hi tinfanide,

It's because your 'Cells' references don't point to the 'sheet'.

BTW, it's not good practice to use names like 'sheet', as you can very quickly get that messed up with '.Sheet'. Furthermore, I see you're still trying to select things. You rarely need to select anything. For example:
Code:
Sub Test()
Dim xlWkBk As Workbook
Dim xlSht As Worksheet
Set xlWkBk = Workbooks("test.xls")
Set xlSht = xlWkBk.Worksheets("Sheet1")
With xlSht
  'do something, eg define a range to work on:
  With .Range(.Cells(23, 2), .Cells(47, 2))
    'do something, eg populate the defined range:
    .Value = Now
  End With
End With
Set xlSht = Nothing: Set xlWkBk = Nothing
End Sub
PS: Your question concerns Excel vba, but you posted it in the Word vba forum. I've moved it to the Excel forum.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Range(Cell1,Cell2) Error on another workbook controlling some other workbook? Shared Workbook SJT Excel 6 01-12-2012 11:33 AM
Loop through folder of workbooks and copy range to other workbook Snvlsfoal Excel Programming 3 07-29-2011 05:55 AM
Range(Cell1,Cell2) Error on another workbook controlling some other workbook? macro to transfer data from one workbook to another workbook virsojour Excel Programming 5 02-01-2011 08:58 PM
Range(Cell1,Cell2) Error on another workbook controlling some other workbook? Select a range in one one workbook while working in other workbook Slow&Steady Excel 1 02-21-2010 03:34 AM
Share Workbook cannot merge Ichigo Excel 3 01-19-2010 03:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft