Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15908

MsOf13 How do we remake the program to copy not one value value but with range in column age

$
0
0
How do we remake the program to copy not one value value but with range in column age? We need copy all values from age.xlsm age column to another age column in shchool.xlsm file

school.xlsm

A B
name age
peter1
jane2
ted
peter3
age.xlsm
A B
name age
mark3 1,2
peter1 5
jane2 1,5
the program copy one value, how do we copy all values from age column from age.xlsm to shool.xlsm file

Sub copydata()
Dim iAge As Integer
Set src = Workbooks.Open("age.xlsm", True, True)
iAge = src.Worksheets("Sheet1").Range("B2").Value
ThisWorkbook.Worksheets("Sheet1").Range("В2").Value = iAge
End Sub
Edit: Code added from comment

Sub Insertdata()
Dim iAge As Integer
Set src = Workbooks.Open("age.xlsm", True, True)
t = 2
lastrow = ActiveSheet.UsedRange.Rows.Count
Do Until t = lastrow
iAge = src.Worksheets("Sheet1").Range("B" & t).Value
ThisWorkbook.Worksheets("Sheet1").Range("B" & t).Value = iAge
t = t + 1
Loop
End Sub
the last makros return wrong output jane2 must be value of 1,5 and it is not it is 5 we need return connected date with key name

Viewing all articles
Browse latest Browse all 15908

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>