Gan mang array cho Range nhung khong duoc

Liên hệ QC

ilvba

Thành viên mới
Tham gia
24/6/19
Bài viết
32
Được thích
7
Mã:
Sub test()
Dim arr(1 to 10) as integer
Dim i as integer
For i = 1 to 10 step 1
arr(i) =i
Next i
Thisworkbook.sheets(1).Range(Cells(1,1),cells(10,1)).value = arr
End sub
Anh chi cho em hoi, sao tat cac cac o deu = 1 @@
 
Tai vi duong su su dung mang mot chieu.
Di tim cac thot noi ve cach lien he mang mot chieu voi range.
Bao gio tim duoc cach go dau tieng Viet, sua bai lai roi se chi ro hon.
 
Sub test()
Dim arr(1 To 10) As Integer
Dim i As Integer
For i = 1 To 10 Step 1
arr(i) = i
ThisWorkbook.Sheets(1).Cells(i, 1).Value = arr(i)
Next i
End Sub

Còn nếu chỉ định dòng bắt đầu từ dòng 5 thì có thể thay ThisWorkbook.Sheets(1).Cells(i, 1).Value = arr(i) thành ThisWorkbook.Sheets(1).Cells(4+i, 1).Value = arr(i)
 
Mã:
Sub test()
Dim arr(1 to 10) as integer
Dim i as integer
For i = 1 to 10 step 1
arr(i) =i
Next i
Thisworkbook.sheets(1).Range(Cells(1,1),cells(10,1)).value = arr
End sub
Anh chi cho em hoi, sao tat cac cac o deu = 1 @@
Bạn thử.
Mã:
Sub test()
Dim arr(1 To 10) As Integer
Dim i As Integer
For i = 1 To 10 Step 1
arr(i) = i
Next i
ThisWorkbook.Sheets(1).Range(Cells(1, 1), Cells(10, 1)).Value = Application.Transpose(arr)
ThisWorkbook.Sheets(1).Range(Cells(1, 1), Cells(1, 10)).Value = arr
End Sub
 
Web KT
Back
Top Bottom