Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Get data from 2nd workbook

Need help with code below keep getting "Script out of range message.

HC.xls Target File
HCE Worksheet
Column "B2:B65536" range with code #
code # format = #####.## - ## - ###

HC_DB.xls Source File
M_DATA Worksheet
Column "B2:B65536" range with Code #
code # format = #####.## - ## - ###

Goal : match Code# in HC with code# in HC_DB & return offset value t
HC

'From HC.xls
Private Sub CommandButton1_Click()
Dim cl As Range

Workbooks.Open Filename:="C:\LKUP\HC_DB.XLS"
Application.Windows("HC.XLS").Activate

' 'GET DATA
For Each cl I
Workbooks("HC").Worksheets("HCE").Range("B2"
Workbooks("HC").Worksheets("HCE").Range("B65536"). End(xlUp).Address)
If Trim(cl.Offset(1, 0).Text)
Workbooks("HC_DB").Worksheets("M_DATA").Range("B2"
Workbooks("HC_DB").Worksheets("M_DATA").Range("B65 536").End(xlUp).Address
_
Then
Wit
Workbooks("HC").Worksheets("HCE").Range("B65536"). End(xlUp).Offset(1
0).Value = cl.Value
' 'LOCATION ON SHEET2 FROM LOCATION O
SHEET1
.Offset(0, 1).Value = cl.Offset(0, 1).Value
.Offset(0, 2).Value = cl.Offset(0, 4).Value
.Offset(0, 3).Value = cl.Offset(0, 6).Value
.Offset(0, 4).Value = cl.Offset(0, 7).Value
.Offset(0, 5).Value = cl.Offset(0, 8).Value
End With
End If
Next cl

Workbooks("HC_DB.XLS").Close SaveChanges:=False
End Su

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Excel VBA - Get data from 2nd workbook

Hi
in which line do you get the error
Maybe the Offset statement do not work as the left side is not using an
object reference

--
Regards
Frank Kabel
Frankfurt, Germany


Need help with code below keep getting "Script out of range message.

HC.xls Target File
HCE Worksheet
Column "B2:B65536" range with code #
code # format = #####.## - ## - ###

HC_DB.xls Source File
M_DATA Worksheet
Column "B2:B65536" range with Code #
code # format = #####.## - ## - ###

Goal : match Code# in HC with code# in HC_DB & return offset value to
HC

'From HC.xls
Private Sub CommandButton1_Click()
Dim cl As Range

Workbooks.Open Filename:="C:\LKUP\HC_DB.XLS"
Application.Windows("HC.XLS").Activate

' 'GET DATA
For Each cl In
Workbooks("HC").Worksheets("HCE").Range("B2",
Workbooks("HC").Worksheets("HCE").Range("B65536"). End(xlUp).Address)
If Trim(cl.Offset(1, 0).Text) =
Workbooks("HC_DB").Worksheets("M_DATA").Range("B2" ,

Workbooks("HC_DB").Worksheets("M_DATA").Range("B65 536").End(xlUp).Addre
ss)
_
Then
With
Workbooks("HC").Worksheets("HCE").Range("B65536"). End(xlUp).Offset(1,
0).Value = cl.Value
' 'LOCATION ON SHEET2 FROM LOCATION ON
SHEET1
Offset(0, 1).Value = cl.Offset(0, 1).Value
Offset(0, 2).Value = cl.Offset(0, 4).Value
Offset(0, 3).Value = cl.Offset(0, 6).Value
Offset(0, 4).Value = cl.Offset(0, 7).Value
Offset(0, 5).Value = cl.Offset(0, 8).Value
End With
End If
Next cl

Workbooks("HC_DB.XLS").Close SaveChanges:=False
End Sub


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Get data from 2nd workbook

The first line below 'get data
I think it has to do win
Dim Array
Dim Cell

Look at attachment code
source file attache

Attachment filename: hc_db.xls
Download attachment: http://www.excelforum.com/attachment.php?postid=54754
--
Message posted from http://www.ExcelForum.com

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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
save excel as data only to a new workbook using VB Haldane Excel Discussion (Misc queries) 0 October 30th 06 01:44 PM
copy excel workbook to new workbook without data Omnitool Excel Worksheet Functions 3 March 14th 06 10:49 PM
looking up data from an other excel workbook Dave New Users to Excel 1 September 7th 05 02:45 PM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM


All times are GMT +1. The time now is 09:47 AM.

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"