View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Terry Pinnell[_4_] Terry Pinnell[_4_] is offline
external usenet poster
 
Posts: 192
Default Copy multi-line variable to first empty row

I have a string variable 'tAll_VBA' in my workbook 'WalkIndex.xlsm',
sheet 'Target'. It contains 21 values on 21 separate lines, all ending
in a CR/LF character. I want to copy all except the first two lines to
19 specified columns of the first empty row of the worksheet (i.e col A
empty). The variable and target cols are as follows:

Destination Source
WalkIndex Line number
column in tVBA_All
---------- ------------
No copy 2
A 4
B 5
C 3
H 11
I 9
J 6
K 7
L 8
M 10
N 12
O 13
P 14
R 15
S 16
T 17
U 19
V 18
W 20
Y 21
Not copied 1

I'm not sure how that mapping will be displayed after pressing Send so
here it is again in Line order:

Col Line
1
2
C 3
A 4
B 5
J 6
K 7
L 8
I 9
M 10
H 11
N 12
O 13
P 14
R 15
S 16
T 17
V 18
U 19
W 20
Y 21

I have previously used the following successfully in another macro to
get the last row:

Set wi = Workbooks("WalkIndex.xlsm")
Set ws = wi.Sheets("Target")

'Find the first empty row (col A) in WalkIndex
With ws
'Find first empty row (last used + 1)
nr = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
'MsgBox nr

Any pointers on how to code this would be much appreciated please.

Terry, UK