Please do not make major edits to a post after you have had responses because it makes another confusing mess: All the following posts now look stupid because they are answering a different question
But its not a major problem this time as the modification is not too difficult. No big deal this time.
So now, it is similar, but no longer a copy, paste. Instead the row values are doubled. Before and After screenshots are here https://excelfox.com/forum/showthrea...ll=1#post13388
Note: I think your supplied After is wrong! - L&TFH should not be considered from Actual File.xlsx, because J of that row is not 1
Before
_____ Workbook: 2.xlsx ( Using Excel 2007 32 bit )
Row\Col |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
O |
1 |
Stock Name |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
2 |
ACC |
100 |
108 |
120 |
128 |
134 |
151 |
6534 |
30 |
90 |
97 |
103 |
|
|
|
3 |
ADANIENT |
101 |
109 |
121 |
127 |
135 |
122 |
782 |
40 |
92 |
98 |
|
|
|
|
4 |
ADANIPORTS |
102 |
110 |
122 |
16 |
137 |
177 |
10 |
50 |
93 |
99 |
104 |
|
|
|
5 |
ASHOKLEY |
1 |
2 |
3 |
4 |
5 |
16 |
137 |
177 |
10 |
50 |
93 |
99 |
104 |
|
6 |
EQUITAS |
10 |
50 |
93 |
99 |
5 |
102 |
110 |
122 |
9 |
10 |
11 |
|
|
|
7 |
L&TFH |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Worksheet: Sheet1 (4)
If column J has data in actual file.xlsx then match column B of actual file.xlsx with column A of sheet 1 of 2.xlsx and if it matches then double the value of that row of 2.xlsx
After
_____ Workbook: 2.xlsx ( Using Excel 2007 32 bit )
Row\Col |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
O |
1 |
Stock Name |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
data |
2 |
ACC |
100 |
108 |
120 |
128 |
134 |
151 |
6534 |
30 |
90 |
97 |
103 |
|
|
|
3 |
ADANIENT |
101 |
109 |
121 |
127 |
135 |
122 |
782 |
40 |
92 |
98 |
|
|
|
|
4 |
ADANIPORTS |
102 |
110 |
122 |
16 |
137 |
177 |
10 |
50 |
93 |
99 |
104 |
|
|
|
5 |
ASHOKLEY |
2 |
4 |
6 |
8 |
10 |
32 |
274 |
354 |
20 |
100 |
186 |
198 |
208 |
|
6 |
EQUITAS |
20 |
100 |
186 |
198 |
10 |
204 |
220 |
244 |
18 |
20 |
22 |
|
|
|
7 |
L&TFH |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Worksheet: Sheet1 (4)
This is the important code change
Question 1
Code:
Else ' Cnt is now at the row number of where 2.xlsx sheet1 column A was found in Actual File.xlsx sheet1 column B
Dim Lc1Cnt As Long: Let Lc1Cnt = Ws1.Cells.Item(Cnt, Ws1.Columns.Count).End(xlToLeft).Column
Ws1.Range("B" & Cnt & ":" & CL(Lc1Cnt) & Cnt & "").ClearContents ' clear row Cnt of all data before pasting
Rng22.Copy Destination:=Ws1.Range("B" & Cnt & "") ' copy the (only first row)entire row of data from sheet2 of 2.xlsx and paste it to the row in sheet 1 of 2.xlsx at the row number of the matched value of 2.xlsx sheet1
Question 2
Code:
Else ' Cnt is now at the row number of where 2.xlsx sheet1 column A was found in Actual File.xlsx sheet1 column B
Dim Lc1Cnt As Long: Let Lc1Cnt = Ws1.Cells.Item(Cnt, Ws1.Columns.Count).End(xlToLeft).Column
' Ws1.Range("B" & Cnt & ":" & CL(Lc1Cnt) & Cnt & "").ClearContents ' clear row Cnt of all data before pasting
' Rng22.Copy Destination:=Ws1.Range("B" & Cnt & "") ' copy the (only first row)entire row of data from sheet2 of 2.xlsx and paste it to the row in sheet 1 of 2.xlsx at the row number of the matched value of 2.xlsx sheet1
Let Ws1.Range("B" & Cnt & ":" & CL(Lc1Cnt) & Cnt & "").Value = Ws1.Evaluate("=2*" & Ws1.Range("B" & Cnt & ":" & CL(Lc1Cnt) & Cnt & "").Address & "") ' then double the value of that row of 2.xlsx
Full macro Here https://excelfox.com/forum/showthrea...ll=1#post13389
( dont forget that you still need the Function Function CL() )
Bookmarks