LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Copying columns (but cells should be copied in different order

fYou need to have a beginning and end line that I put into the code like I
did below

1) to get into VBA type Alt F11
2) In VBA menu Insert Module
3) Past code below
4) from VBA Window check code in menu Debug - compile VBA Project
5) You can run code a few difffernt ways
a) From VBA Window press F5
b) from VBA window menu Run - Run
c) from worksheet menu Tools - Macro - Macro - (macro Name) Run
d) from worksheet menu Tools - Macro - Macro. select Options and set a
hot key to run macro
e) Put a control button on worksheet/toolbar and use button to start
macro. Will explain if you need this option


There are also macro the are triggered fron event.


Sub Getmaterial

set bk1sht = workbooks("book1.xls").sheets("Sheet1")
set bk2sht = workbooks("book2.xls").sheets("Sheet1")

with bk1sht
RowCount = 1
do while .Range("A" & RowCount) < ""
Material = .Range("A" & RowCount)

set c = bk2sht.Columns("A").find(what:=Material, _
lookin:=xlvalues,lookat:=xlwhole)
if c is nothing then
msgbox("Cannot find : " & material)
else
.Range("Z" & Rowcount) = bk2sht.Range("C" & c.row)
end if
RowCount = RowCount + 1
loop
end with

end sub

" wrote:

Hello Joel,

Thank you very much for the reply. But a basic question (as I am a
total beginner), how to run this script. I tried with the inbuilt, VBE
but I dont know which button to press. Thank you

Suresh

On Aug 28, 12:39 pm, Joel wrote:
set bk1sht = workbooks("book1.xls").sheets("Sheet1")
set bk2sht = workbooks("book2.xls").sheets("Sheet1")

with bk1sht
RowCount = 1
do while .Range("A" & RowCount) < ""
Material = .Range("A" & RowCount)

set c = bk2sht.Columns("A").find(what:=Material, _
lookin:=xlvalues,lookat:=xlwhole)
if c is nothing then
msgbox("Cannot find : " & material)
else
.Range("Z" & Rowcount) = bk2sht.Range("C" & c.row)
end if
RowCount = RowCount + 1
loop
end with



" wrote:
Hello All,


I have two excel files. In both the excel files I have about 1300 rows
of data. These are different datas of the same material. For example
"material A" (the material information in both the files is in column
A) in file 1 is in row 13 and the same "material A" in file 2 is in
row 1201. I am trying to write a script which can take one file say
file 1 (for simplicity) and go to row 1 (of worksheet 1) and read the
material name (say "material xyz") and locate this material in file 2
(may be this same "material xyz" exist in row 1100 in file 2) and copy
a specific cell (say cell in column c, which means for this example,
cell c1100) to file1 in the same worksheet but in a specific column z
(so copy from file 2, cell c1100 TO file 1, cell z1). Can anyone help
me.


Thanks


Suresh- Hide quoted text -


- Show quoted text -



 
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
Copying worksheets with formulas in hidden columns Brian Excel Worksheet Functions 2 August 14th 08 10:03 PM
Copying worksheets into different Excel files Sonia Marie Excel Discussion (Misc queries) 1 February 15th 07 08:46 PM
Copying columns and automating data updates across worksheets jkl Excel Discussion (Misc queries) 3 February 13th 07 07:04 PM
Copying individual files (workbooks) into worksheets jay Excel Programming 2 October 11th 05 06:32 PM
zero value when copying cells between worksheets joe Excel Discussion (Misc queries) 1 August 9th 05 08:51 PM


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

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"