LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default first sip of working with range in vba excel

Hi,

I have started learning vba for excel. Now, I feel fine with cells
workarounds in a loop or else. But when it comes to a range, I can't
find the reason why if I'm following the excel object model it's not
working.

Sub tryingtocopyrange()

Dim wkb1 As Workbook 'copy from wkb1
Dim wkb2 As Workbook 'copy to wkb2
Dim wks1 As Worksheet 'source sheet for wkb1
Dim wks2 As Worksheet 'destination sheet for wkb2

Set wkb1 = Workbooks("source.xls")
Set wkb2 = Workbooks("desti.xls")
Set wks1 = wkb1.Worksheets("mysource")
Set wks2 = wkb2.Worksheets("mydesti")

'A - the following is not working
'wks2.Range(Cells(1, 1), Cells(10, 3)) = wks1.Range(Cells(1, 1),
Cells(10, 3)).Value

'B - this is working but i'd rather use the cell method as i find it
easier to play with variables for indices in a loop
'wks2.Range("A1:C10") = wks1.Range("A1:C10").Value

'C - using the copy method, I should be able to copy a range and set
one cell as a destination
wks1.Range(Cells(1, 2), Cells(10, 2)).Copy
Destination:=wks2.Cells(4, 1)

End Sub

This little step that makes my life hard as a non-programmer trying to
code in vba, once over would take me to bigger steps such as copying
range into vba arrays...

Thanks,
Pascal





 
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
Working with Range Robin Clay[_4_] Excel Programming 3 November 7th 08 07:53 PM
Working with a range Dan Chupinsky Excel Discussion (Misc queries) 3 July 6th 05 06:39 AM
Working with range François Excel Programming 6 April 28th 05 01:37 PM
Macro working in Excel 2003; not working in Excel 2000 Leslie Barberie Excel Programming 5 May 20th 04 07:51 PM
Excel VBA-Error, range function not working?!?!? waveracerr[_15_] Excel Programming 2 February 13th 04 08:11 PM


All times are GMT +1. The time now is 12:58 PM.

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

About Us

"It's about Microsoft Excel"