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 7916211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:43:30+00:00 2026-06-03T14:43:30+00:00

I am receiving a large file 500k+ lines but all the content is in

  • 0

I am receiving a large file 500k+ lines but all the content is in column A. I need to run a macro that will transpose the data into matrix form but will only create a new row when it finds "KEY*" in the ActiveCell. For example:

| KEY 4759839 | asljhk | 35049 | | sklahksdjf|
| KEY 359     | skj    | 487   |y| 2985789   |

The above data in my file would originally look like this in column A:

KEY 4759839
asljhk
35049

sklahksdjf
KEY 359
skj
487
y
2985789

Considerations:

  • Blank cells need to be transposed as well, so the macro cant stop based on emptyCell
  • The number of cells between KEY’s is not constant so it actually needs to read the cell to know if it should create a new row
  • It can either stop based on say 20 empty cells in a row or prompt for a max row number
  • (Optional) It would be nice if there was some sort of visual indicator for the last item in a row so that its possible to tell if the last item(s) were blank cells

I searched around and found a macro that had the same general theme but it went based on every 6 lines and I did not know enough to try to modify it for my case. But in case it helps here it is:

Sub kTest()
    Dim a, w(), i As Long, j As Long, c As Integer
    a = Range([a1], [a500000].End(xlUp))
    ReDim w(1 To UBound(a, 1), 1 To 6)
    j = 1
    For i = 1 To UBound(a, 1)
        c = 1 + (i - 1) Mod 6: w(j, c) = a(i, 1)
        If c = 6 Then j = j + 1
    Next i
    [c1].Resize(j, 6) = w
End Sub

I would greatly appreciate any help you can give me!

  • 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-03T14:43:31+00:00Added an answer on June 3, 2026 at 2:43 pm

    Tested and works:

        Sub test()
        Row = 0
        col = 1
    
        'Find the last not empty cell by selecting the bottom cell and moving up
        Max = Range("A650000").End(xlUp).Row 'Or whatever the last allowed row number is
    
        'loop through the data
        For i = 1 To Max
            'Check if the left 3 characters of the cell are "KEY" and start a new row if they are
            If (Left(Range("A" & i).Value, 3) = "KEY") Then
                 Row = Row + 1
                 col = 1
            End If
    
            Cells(Row, col).Value = Range("A" & i).Value
            If (i > Row) Then
                Range("A" & i).Value = ""
            End If
            col = col + 1
    
        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'm about to start work on a large project that will involve providing a
I'm developing an application that will need to communicate with itself running on different
I need to build a windows server side application that will be responsible for
I am doing my transformation in php. I am receiving a large XML file
I did the following, mysqld.exe --defaults-file=D:\my-large.ini I changed the max_allowed_packets inside of that .ini
I am receiving this Uncaught TypeError on a new website I am creating, but
I am receiving shouldstartloadwithrequest event and I need to stop request for some conditions.
I am receiving Invalid Index COM exception when calling Excel.AddIns.Item[0] . Excel.AddIns.Count works all
I've got a c++ app that wraps large parts of code in try blocks.
A client is trying to send a rather large email but it gets bounced

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.