Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8330419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:07:08+00:00 2026-06-09T02:07:08+00:00

I have a simple piece of code written which basically scans through column A,

  • 0

I have a simple piece of code written which basically scans through column A, detects for a condition and once the condition is met in a row, it copies the cell in column B of the same row into an array. I was hoping someone could help me make a nested array which would not only store the value in column B but also its rowcount. here is what i have so far, any help is appreciated.

Dim col2 As Range
Dim cell2 As Excel.Range
Dim rowcount2 As Integer
Dim ii As Integer

ii = 0
rowcount2 = DataSheet.UsedRange.Rows.Count
Set col2 = DataSheet.Range("A1:A" & rowcount2)
Dim parsedcell() As String
Dim oldarray() As String

    For Each cell2 In col2

        If cell2.Value <> Empty Then
            parsedcell = Split(cell2.Value, "$")
            sheetName = parsedcell(0)

                If sheetName = DHRSheet.Name Then

                    Dim oldvalue As Range
                    ReDim Preserve oldarray(ii)
                    Set oldvalue = DataSheet.Cells(cell2.Row, 2)

                    oldarray(ii) = oldvalue.Value

                    ii = ii + 1

                End If

      End If

    Next
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:07:09+00:00Added an answer on June 9, 2026 at 2:07 am

    You need a two dimensional array. Use one dimension for the value and the other for the row. Here’s an example

    Sub GetArray()
    
        Dim vaInput As Variant
        Dim rRng As Range
        Dim aOutput() As Variant
        Dim i As Long
        Dim lCnt As Long
    
        'Define the range to test
        Set rRng = DataSheet.Range("A1", DataSheet.Cells(DataSheet.Rows.Count, 1).End(xlUp)).Resize(, 2)
        'Put the values in that range into an array
        vaInput = rRng.Value
    
        'Lopo through the array
        For i = LBound(vaInput, 1) To UBound(vaInput, 1)
            'Skip blank cells
            If Len(vaInput(i, 1)) > 0 Then
                'Test for the sheet's name in the value
                If Split(vaInput(i, 1), "$")(0) = DHRSheet.Name Then
                    'Write the value and row to the output array
                    lCnt = lCnt + 1
                    'You can only adjust the second dimension with a redim preserve
                    ReDim Preserve aOutput(1 To 2, 1 To lCnt)
                    aOutput(1, lCnt) = vaInput(i, 2) 'write the value
                    aOutput(2, lCnt) = i 'write the row count
                End If
            End If
        Next i
    
        'Output to see if you got it right
        For i = LBound(aOutput, 2) To UBound(aOutput, 2)
            Debug.Print aOutput(1, i), aOutput(2, i)
        Next i
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple piece of code written to open a report. Private Sub
I have written the following piece of code that reads through a given xml-file
I have written a piece of Java code which is intended as to call
I have a simple plugin system in a piece of code I have written.
I have a problem with a very simple piece of code written in Javascript,
I have this simple piece of code : int a = 1, b =
I have very simple piece of code. The goal is when i input four-digit
I have a simple piece of code: txtRequiredDate.setText(wwDateFormatter.format(todoEntity.getRequiredDate())); txtRequiredDateDay.setText(dayOfWeek(todoEntity.getRequiredDate())); txtDoneDate.setText(wwDateFormatter.format(todoEntity.getDoneDate())); txtDoneDateDay.setText(dayOfWeek(todoEntity.getDoneDate())); Problem is that
I have this simple piece of code: MyObjectContext db = new MyObjectContext(); Person new_person
I have a simple piece of c++ code: #include <iostream> using namespace std; int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.