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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:19:27+00:00 2026-06-14T09:19:27+00:00

The code at the bottom copies columns individually from one sheet to another and

  • 0

The code at the bottom copies columns individually from one sheet to another and performs text to columns one by one. for example, after column A has been taken care of, the Text to columns procedure for column B (first sheet) is supposed to begin in the next available empty column in the second sheet.

The rows in the first sheet are of different lengths. So column A might have cells A1:A25 full but column N might only have some of its cells full because some of the rows have ended.

This code works fine until it encounters the first partially full column and then it keeps pasting columns into the same column.

I thought the line below would take care of this but it doesn’t seem to work:

If Application.WorksheetFunction.CountA(Excel.Sheets("Organise_R").Columns(b)) > 0  Then b = b + 1

I’ve been trying for the last few hours but I’ve had no success.Any help would be much appreciated! Thanks in advance!

For a = 1 To 60

'If Excel.WorksheetFunction.CountBlank(Excel.Sheets("Import_R").Columns(a)) < 1048576
If Application.WorksheetFunction.CountA(Excel.Sheets("Import_R").Columns(a)) > 0 Then

    Excel.Sheets("Import_R").Columns(a).Copy

    b = Excel.Sheets("Organise_R").Cells(1, Columns.Count).End(Excel.xlToLeft).column

    Excel.Sheets("Organise_R").Select

    'If Cells(1, b) <> ""
    'If Excel.WorksheetFunction.CountBlank(Excel.Sheets("Organise_R").Columns(b)) < 1048576 Then
    If Application.WorksheetFunction.CountA(Excel.Sheets("Organise_R").Columns(b)) > 0 Then b = b + 1


        Excel.Sheets("Organise_R").Columns(b).EntireColumn.Select
        Excel.ActiveSheet.Paste

        Excel.Application.CutCopyMode = False
        Selection.TextToColumns Destination:=Cells(1, b), DataType:=xlDelimited, _
                TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
                Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
                :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
                Array(7, 1), Array(8, 1)), TrailingMinusNumbers:=True

End If



Next a
  • 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-14T09:19:28+00:00Added an answer on June 14, 2026 at 9:19 am

    This is not how I would do it – Specifically, I don’t understand your line of code:

    If Application.WorksheetFunction.CountA(Excel.Sheets("Organise_R").Columns(b)) > 0 Then b = b + 1
    

    Since I owuld assume you owuld need a loop here to find the last column, but this is a different matter.

    But I think to answer your question, you would be better off using the UsedRange method to find the last column in your sheet, maybe something like this:

        b = Excel.Sheets("Organise_R").UsedRange.Columns.Count
    

    To replace your line:

        b = Excel.Sheets("Organise_R").Cells(1, Columns.Count).End(Excel.xlToLeft).column
    

    Hope this helps.

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

Sidebar

Related Questions

This is the code. I want to align text at bottom <p style=background:#eee;font-size:1.3em;color:#022662;height:116px> <img
This code should i place this code at bottom of body it's in conditional
I added the solution to the code below. The code at the bottom is
Anyone have code to set margins(top,left,right,bottom) using excel interop and vb.net. I think it
EDITED SO THE CODE IS CORRECT (THANKS TO ta.speot.is) - NEW QUESTION AT BOTTOM
I have the following code but it doesnt seem to work: <td align=center style=padding-bottom:52.5px>
I have no idea why but only the bottom div works the code is:
I know that I need to add the tracking code snippet at the bottom
I am trying to use a bit of code I found at the bottom
I am populating a UITableViewController's UITableView through code only. At the bottom of the

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.