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

Ihave 4 sheet with similar kind of structure; leftmost column has the
product code and other columns have details (numbers) about those
products.

ProdID Qty
1/art-05-d 200
1/art-05-q 204
1/art-05-s 420

I need to get the qty value and pass it to another sheet to same row
with corresponding ProdID. I cannot paste the whole columns, since not
all of the sheets have same amount of products. So the question is how
can i use the prodID as a "primary key"

Help is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default passing values from one sheet to another

I answered a similar question earlier - perhaps you
missed it...

To FETCH existing data run the following code



Sub FetchAllFiles()
'will open all files in a directory
Dim myPath As String, MyFile As String
Dim WB As Workbook, sheetname As String
Dim rw As Long

myPath = "H:\Excel_Demos\"

MyFile = Dir(myPath & "*.xls")

Do While MyFile < ""

rw = rw + 1

Set WB = Workbooks.Open(myPath & MyFile, False, True)
sheetname = WB.ActiveSheet.Name
WB.Close False

Cells(rw, 1) = MyFile
Cells(rw, 2) = sheetname

MyFile = Dir()
Loop


End Sub

The code opens each file it finds, gets the active
sheet's name, closes th efile without saving it, then
pushes the filename & sheet name to your active sheet.

update columns 3 & 4 with the new file name in 3 ("C")
and the new sheet name in 4 ("D") then run the following
procedu

Sub UpdateAllFiles()
'will open all files in a directory
Dim myPath As String, MyFile As String
Dim WB As Workbook, sheetname As String, newFilename As
String
Dim rw As Long

myPath = "H:\Excel_Demos\"

rw = 1

Do While Cells(rw, 1) < ""

MyFile = Cells(rw, 1).Value
newFilename = Cells(rw, 3).Value
sheetname = Cells(rw, 4).Value
Set WB = Workbooks.Open(myPath & MyFile, False, True)
WB.ActiveSheet.Name = sheetname
WB.Close True

Name myPath & MyFile As myPath & newFilename

rw = rw + 1
Loop

End Sub

this reads down column 1, fetches the file, renames the
sheet, cloases & saves the file, then renames the file.

Patrick Molloy
Microsoft Excel MVP


-----Original Message-----
Ihave 4 sheet with similar kind of structure; leftmost

column has the
product code and other columns have details (numbers)

about those
products.

ProdID Qty
1/art-05-d 200
1/art-05-q 204
1/art-05-s 420

I need to get the qty value and pass it to another sheet

to same row
with corresponding ProdID. I cannot paste the whole

columns, since not
all of the sheets have same amount of products. So the

question is how
can i use the prodID as a "primary key"

Help is greatly appreciated.
.

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
passing values to other sheets [email protected] New Users to Excel 1 February 23rd 08 02:03 AM
Passing variable values to userform control KJ-clueless Excel Discussion (Misc queries) 2 November 27th 07 10:51 PM
Passing values in Sheet to VBA Jonathan Charts and Charting in Excel 1 June 30th 06 06:00 AM
Userform and passing date values DTM Excel Programming 2 July 23rd 03 04:00 AM
passing data from one sheet to another billabong Excel Programming 4 July 13th 03 01:15 AM


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