How get data massive from Excel List1, List2 and put resoult to List3?

Николай Дроздов 1 Reputation point
2021-06-17T17:43:28.717+00:00

Public Sub Program1()
Dim k(1 To 54) As Integer
Dim dqQ As Single
Dim qQ(100) As Single
Dim rVect(100) As Single
Dim aElips1 As Single
Dim eXcen1 As Single
Dim zub1

ActiveWorkbook.Worksheets("List1").Activate
Dim i(1 To 27) As Integer
Dim j(1 To 100) As Integer
Dim Xcz(30), Rcpk(30), Zp(30), As Double
Dim Xzl(100), Xtzl(100), XAcpk(100) As Double
dqQ = Range("C21")
aElips1 = Range("C3")
eXcen1 = Range("C9")
'Get dada massive, List1
For i = 26 To 53
Xcz(i) = Range("Q(25+i)")
Rcpk(i) = Range("AD(25+i)")
'Calculate massive
XAcpk(i) = Xcz(i) - Rcpk(i)
'Go to List2
ActiveWorkbook.Worksheets("List1").Deactivate
ActiveWorkbook.Worksheets("List2").Activate
Cells(D9) = Zp(i)
ActiveWorkbook.Worksheets("Лист2").Calculate
'Calculation for i, j massive
For j = 1 To 100
Xzl(j) = Range("Q(5+j)")
Xtzl(i, j) = XAcpk(i) + Xzl(j)
'Write I, j massive to List3
ActiveWorkbook.Worksheets("List2").Deactivate
ActiveWorkbook.Worksheets("List3").Activate
Cells(2 + 11 * (i - 1), 4 + j).Value = Xtzl(i, j)
ActiveWorkbook.Worksheets("List3").Deactivate
ActiveWorkbook.Worksheets("List1").Activate
Next
Next
End Sub

Developer technologies VB
{count} votes

2 answers

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2021-06-18T01:49:06.327+00:00

    Hello,

    I don't see list but instead arrays. You can combine arrays using Concat.

    The following extension methods are generic so they work the same for string, int, double etc.

    Imports System.Runtime.CompilerServices  
      
    Public Module GenericArrayExtensions  
      
        <Extension> _  
        Public Function Add(Of T)( sequence As IEnumerable(Of T),  item As T) As IEnumerable(Of T)  
            Return (If(sequence, Enumerable.Empty(Of T)())).Concat( { item })  
        End Function  
      
        <Extension> _  
        Public Function AddRange(Of T)( sequence() As T,  items() As T) As T()  
            Return (If(sequence, Enumerable.Empty(Of T)())).Concat(items).ToArray()  
        End Function  
      
        <Extension> _  
        Public Function AddToArray(Of T)( sequence() As T,  item As T) As T()  
            Return Add(sequence, item).ToArray()  
        End Function  
    End Module  
      
      
    
    0 comments No comments

  2. Николай Дроздов 1 Reputation point
    2021-06-19T16:33:14.797+00:00

    107282-calculate-centroid-1.txt

    Hi all!

    I'm sending you List1
    The extension methods are generic for string is not possible.
    Arrays in the form of columns and for them need to specify an identifier with indexes for each array.
    The program will have additional calculations (xslm BV) and the results should be recorded on sheet 3 by colomns.
    --
    Nikolai Drozdov

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.