VB code:
Sub Excel_matrix_to_sas()
output_cell = InputBox("请输入输出单元格位置。例如:A1")
i = Selection.Rows.Count
j = Selection.Columns.Count
st_1 = "'={"
With Selection
For m = 1 To i
For n = 1 To j
If n = 1 Then
st_1 = st_1 & .Cells(m, n).Value
Else
st_1 = st_1 & " " & .Cells(m, n).Value
End If
Next
If m <> i Or (n - 1) <> j Then
st_1 = st_1 & ","
End If
Next
st_1 = st_1 & "}"
End With
Range(output_cell).Value = st_1
End Sub



雷达卡


京公网安备 11010802022788号







