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

  • SEARCH
  • Home
  • 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 8479875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:09:16+00:00 2026-06-10T19:09:16+00:00

I am really new to VBA coding. Problem I have is this: B60, D60,

  • 0

I am really new to VBA coding.

Problem I have is this:

B60, D60, F60, H60 (etc) cells have different values in this format: x, y, z
(x, y and z can be numbers 0-10)
I’d like to splice this so it becomes:

B60 = x
B61 = y
B62 = z
D60 = x2
D61 = y2
D62 = z2

etc.

I’ve found this code:

Dim objRegex
Dim Z
Dim Y
Dim lngRow As Long
Dim lngCnt As Long
Dim tempArr() As String
Dim strArr
Set objRegex = CreateObject("vbscript.regexp")
objRegex.Pattern = "^\s+(.+?)$"
'Define the range to be analysed
Z = Range([a1], Cells(Rows.Count, "b").End(xlUp)).Value2
ReDim Y(1 To 2, 1 To 1000)
For lngRow = 1 To UBound(Z, 1)
'Split each string by ","
tempArr = Split(Z(lngRow, 2), ",")
For Each strArr In tempArr
lngCnt = lngCnt + 1
'Add another 1000 records to resorted array every 1000 records
If lngCnt Mod 1000 = 0 Then ReDim Preserve Y(1 To 2, 1 To lngCnt + 1000)
Y(1, lngCnt) = Z(lngRow, 1)
Y(2, lngCnt) = objRegex.Replace(strArr, "$1")
Next
Next lngRow
'Dump the re-ordered range to columns C:D
[a1].Resize(lngCnt, 2).Value2 = Application.Transpose(Y)

But this doesn’t quite work for me. I only need row 60 to do this. I really tried editing this code, but I don’t understand any of it… Can someone help me out please? It’s really appreciated.

  • 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-10T19:09:17+00:00Added an answer on June 10, 2026 at 7:09 pm

    This will do the trick for you. Works only on row 60, and will not overwrite the existing values, so you can check for accuracy. Will only work for 3 comma-separated values in each cell.

    'Required declaration for the arrays to be 0-based in VBA.
    Option Base 0
    
    'Routine to split out the values and place them vertically under the original cell.
    Sub SplitItOut()
        'Variable to hold the contents of the cell in question.
        Dim contents
        'Column number of the column to start searching for data in.
        Dim startColumn As Integer
        'Counter variable used to keep track of the current column.
        Dim columnCounter As Integer
        'Array to store the comma-separated values in, after they have been separated from their commas.
        Dim numArray() As String
        Dim i As Integer
    
        columnCounter = 0
    
        'Starting column is 2 which is "B".
        startColumn = 2
        'Read in the initial contents of "B60". Cells function is using (row 60, column 2) style notation.
        contents = Cells(60, startColumn).Value
    
        'Keep looping until there is nothing but an empty string in the contents variable.
        Do While contents <> ""
            'Split out the numbers in the cell and store them in an array.
            numArray = Split(contents, ",", -1)
            'Loop through the 3 entries in the array.
            For i = 0 To 2
                'Place each entry in successive rows below the original cell.
                'The Trim function is used to remove any potential extra spaces from the number.
                Cells(61 + i, startColumn + columnCounter).Value = Trim(numArray(i))
            Next
            'Move to the next column.
            columnCounter = columnCounter + 1
            'Read in its contents.
            contents = Cells(60, startColumn + columnCounter).Value
            'If the contents are empty, move to the next column.
            If contents = "" Then
                columnCounter = columnCounter + 1
            End If
            'If the next column is also empty, the loop will exit, otherwise it will continue with the new contents of the current column.
            contents = Cells(60, startColumn + columnCounter).Value
        Loop
    End Sub
    

    If you have a varying number of comma-separated values in each cell, you will need to change the line:

    For i = 0 To 2
    

    to

    For i = 0 to Ubound(numArray)
    

    EDIT

    Fixed code to work with 1 blank column between each column of data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really new to Python and coding in general, but I have been making
im really new to linq-to-SQL so this may sound like a really dumb question,
I am really new to java (started learning 2 days ago). Sorry if this
I'm really new to this, and I've been going through the YARD docs ,
I am really new to the programming but I am studying it. I have
I am really new with PHP and all I have to do is to
Im really really new to Javascript but Ive got this script that loads the
I am really new with vba , so please forgive my slaughtering of the
Hi i'm new to vba and i might not really undestand much of it,
I'm new with VBA and I'm stuck somewhere. I have to copy last row

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.