Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 310
Default transfer data from one workbook to another.

Hi,

I am trying to write detail records from one spreadsheet to the other. B2 is
used to select records(marked with an "x") I want to transfer a part
number(C2) if B2 = "x". So if B2 = "x" transfer C2.
Can I build an array for this? Also, I'd like to add some hard-coded fields
to that spreadsheet as well. For example, UOM = "EA", Action = "Add", A count
of detail lines added that's formatted as 0010,0020,0030... Here is the code
I'm trying to use. Thank You for your help.

At this point I'm just trying to write 1 column to the other spreadsheet.

Set rnData = ActiveSheet.Range("B11:C150")
vaData = Application.Transpose(rnData.Value)

Set cnt = New ADODB.Connection
Set rst = New ADODB.recordset

Set wbSource = ThisWorkbook
Set wsSheet = wbSource.Worksheets("Deliverables")
stWbtarget = (strPath & strFileName)

stConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & stWbtarget & ";" & _
"Extended Properties='Excel 8.0;HDR=No';"

'"Data Source=" & CurrentProject.Path & "\" & strExcelName & ";" _

vaData = rnData.Value

cnt.Open stConn

'SQL statement for BLS
stSQL = "SELECT * FROM [Sheet1$D10:D300]"

With rst
.CursorLocation = adUseClient
.Open stSQL, cnt, adOpenForwardOnly, adLockOptimistic, adCmdText
End With

For i = 1 To UBound(vaData)

With rst
.AddNew
If (vaData(i, 1)) = "x" Then
.Update VBA.Array(vaData(i, 2))
End If
End With
Next i
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 transfer data from one workbook to another with VB Dan Worley Excel Programming 5 August 2nd 08 08:09 AM
How to transfer data from one workbook to another via VBA Adnan Excel Discussion (Misc queries) 0 August 1st 08 06:42 PM
Transfer data from one workbook to another workbook based on a key Luther Excel Programming 2 September 15th 07 04:32 AM
Transfer data from one workbook to a form in another workbook NCSooner63 Excel Programming 0 May 11th 07 06:42 PM
Data transfer from a template to a workbook Nick Excel Worksheet Functions 0 April 20th 06 05:26 PM


All times are GMT +1. The time now is 11:47 PM.

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"