Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Get Data from Second Workbook "Please Help"

I am trying to get data from a second file in same folde
What am I missing. Code reads as follows

CommandButton1 is in HC.xls Tab H

Private Sub CommandButton1_Click(
Dim xl As New Excel.Applicatio
Dim xlw As Excel.Workboo
Set xlw = xl.Workbooks.Open("C:\LKUP\HC_DB.XLS"
xlw.Sheets("m_data").Selec

'GET DAT
For Each CL In Worksheets("HC").Range("B1", Worksheets("HC").Range("B65536").End(xlUp).Address
If CL.Offset(1, 0).Text = Worksheets("M_DATA").Range("B2", Worksheets("M_DATA").Range("B65536").End(xlUp).Add ress)
The
With Worksheets("M_DATA").Range("B65536").End(xlUp).Off set(0, 0
.Value = CL.Valu
'LOCATION ON SHEET"HC" FROM LOCATION ON SHEET"HC_DB
.Offset(0, 1).Value = CL.Offset(0, 1).Valu
.Offset(0, 2).Value = CL.Offset(0, 4).Valu
.Offset(0, 3).Value = CL.Offset(0, 6).Valu
.Offset(0, 4).Value = CL.Offset(0, 7).Valu
.Offset(0, 5).Value = CL.Offset(0, 8).Valu
End Wit
End I
Next C

xlw.Close Fals
Set xlw = Nothin
Set xl = Nothin
End Su

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Get Data from Second Workbook "Please Help"

JimO

What is it supposed to do? What's not working?

You shouldn't need to create a new Excel application, just open the workbook
from within the same application. Also, what is CL? It appears to be a
variable, but I don't see it defined anywhere.

If you're getting an error, post the exact text of the error message and the
error number.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com

"JimO" wrote in message
...
I am trying to get data from a second file in same folder
What am I missing. Code reads as follows:

CommandButton1 is in HC.xls Tab HC

Private Sub CommandButton1_Click()
Dim xl As New Excel.Application
Dim xlw As Excel.Workbook
Set xlw = xl.Workbooks.Open("C:\LKUP\HC_DB.XLS")
xlw.Sheets("m_data").Select

'GET DATA
For Each CL In Worksheets("HC").Range("B1",

Worksheets("HC").Range("B65536").End(xlUp).Address )
If CL.Offset(1, 0).Text = Worksheets("M_DATA").Range("B2",

Worksheets("M_DATA").Range("B65536").End(xlUp).Add ress) _
Then
With

Worksheets("M_DATA").Range("B65536").End(xlUp).Off set(0, 0)
.Value = CL.Value
'LOCATION ON SHEET"HC" FROM LOCATION ON

SHEET"HC_DB"
.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

xlw.Close False
Set xlw = Nothing
Set xl = Nothing
End Sub



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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
cannot use "Create List" and "Share Workbook" same time Devendra Excel Discussion (Misc queries) 0 October 26th 06 06:05 AM
Macro to concatenate into "B1" B2 thru B"x" based on new data in "Col A" Dennis Excel Discussion (Misc queries) 0 July 17th 06 02:38 PM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


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