Advanced programming in VBA-Excel for beginners: With examples of DLL libraries and Add-Ins in Visual Basic .NET by Oria Dorian

Advanced programming in VBA-Excel for beginners: With examples of DLL libraries and Add-Ins in Visual Basic .NET by Oria Dorian

Author:Oria, Dorian [Oria, Dorian]
Language: eng
Format: epub
Published: 2018-09-07T16:00:00+00:00


2

Dim r, c As Integer 'r: rows, c: columns

3

With Worksheets("matrices")

4

For r = 1 To 3

5

For c = 1 To 3

6

.Range("G1").Offset(r - 1, c - 1) = .Range("B1").Offset(c - 1, r - 1)

7

Next c

8

Next r

9

End With

10

End Sub

To write the transposed matrix, we have used cell G1 as a pivot and from there we count rows and columns (it is important to note that the rows expand downwards and the columns to the right). When the variables "r" and "c" are equal to 1, then the offset is (0,0), that is, it refers to the same cell G1. From there, we move along the columns (For-Next loop of the variable "c") and then along the rows (For-Next loop of the variable "r").

This form has the advantage that Excel, by default, calls its cells with the notation of letters and numbers. As shown by the previous code, it is easy to locate within the sheet and from there move to the adjacent cells using the offset property. When the Cells notation is used, it is necessary to know the column number, which can be a bit tedious, at least for me. However, it is possible that for many of those who are involved with mathematics, the Cells notation may be more comfortable for them.

9.4



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.