0

I have in mind a new question as:

Row  Columns    
7    C  V  M  G
9    X  P  M  N

Description: "7" is row number written is in 2nd cell in column E and C, V, M, G are the column names written in different cells in front of "7". I want to map the data of C7 , V7 , M7 , and G7 to X9, P9, M9 and N9 respectively Please help.

Actually question is like: There is a sheet in excel workbook which has above mentioned table. table contains basically 2 rows. Row one has a value 7 (which is a row specified by me ) in the first cell of table. and other cells in the first row itself has other contents such as C , A , etc. (which are basically other cells names). The second row basically is the destination address. description is similar to description of first row. Now what i want is that the content of C7 will be copied to content of X9, Content of V7 will be copied to P9 etc......

4

1 に答える 1

0

Excel で次のように設定したとします。

       E      F       G       H       I
 1     
 2     7      C       V       M       G
 3     9      X       P       M       N

次のコードを使用して、C7 を X9、V7 を P9 などにコピーできます。

Sub CopyCellsUsingTable()
    Dim sourceCells As Range, cl As Range
    Dim sourceRow As Long, targetRow As Long

    Set sourceCells = Range("F2:I2")
    sourceRow = Range("E2")
    targetRow = Range("E3")

    For Each cl In sourceCells
        Range(cl.Value & sourceRow).Copy Destination:=Range(cl.Offset(1, 0).Value & targetRow)
    Next cl
End Sub

セル参照を更新する必要がある場合があります。

于 2013-05-06T16:48:21.153 に答える