View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Robert Bruce[_2_] Robert Bruce[_2_] is offline
external usenet poster
 
Posts: 108
Default Starting with A2!

Alen32 wrote:
This code insert values in column a,b and d. I would like to start
with cell A2 instead of A1. Please help.

With wbDest.Sheets("Ark1")

For i = LBound(a) To UBound(a)
.Cells(i, "a") = a(i, 1): .Cells(i, "b") = a(i, 2):
.Cells(i, "d") = a(i, 3)
Next


End With


I think this should work:

dim i As Long, j As Long, k As Long, l As Long
const ROW_START as long = 2

With wbdest.Sheets("Ark1")

j = LBound(a, 1)
k = UBound(a, 1)
l = ROW_START - j
For i = j To k
.Cells(i + l, "a") = a(i, 1)
.Cells(i + l, "b") = a(i, 2)
.Cells(i + l, "d") = a(i, 3)
Next


End With

HTH

Rob