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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:38:57+00:00 2026-05-27T08:38:57+00:00

I have a large VBA script file that references the cells of an excel

  • 0

I have a large VBA script file that references the cells of an excel worksheet. The problem is that the number of the application properties I have placed horizontally is becoming larger than 256, therefore I have to change the orientation of storing the properties.

So instead of accessing a value with .Cells(row, column).Value, I would like to access everything by swapping the rows and columns in the previous call.

I could go from all the code and manually change everything, but I would prefer to use a regular expression. I came up with this to find all the references I need:

Worksheets\(\"xxx\.DAT\"\)\.Cells\([\w +-]{1,15}, [\w +-]{1,15}\)

Results look something like this Worksheets(“xxx.DAT”).Cells(SystemNr + 1, 21 + Row1)

I want to swap the rows with the columns in the call to the Cells property, so the end result should look like Worksheets(“xxx.DAT”).Cells(21 + Row1, SystemNr + 1)

I made a small .NET application and used the code bellow to get all the matches, but how do I swap the rows with the columns in the matches themselves?

string input = tbContent.Text;
foreach (Match match in Regex.Matches(input, tbRegex.Text, RegexOptions.IgnorePatternWhitespace))
{
    tbResult.AppendText(match + Environment.NewLine);
}

Now, for every match I’d like to get a reference of the row index and one of the column index so I can swap them and replace the original text.

Thanks,
Adrian.

  • 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-05-27T08:38:58+00:00Added an answer on May 27, 2026 at 8:38 am

    I am not sure how you source data looks like, but here is a short c# example on how to swap two things:

    String s = "A:B";
    Regex r = new Regex(@"(\w):(\w)");
    
    Console.WriteLine(r.Replace(s, "$2:$1"));
    

    If you create a capturing group, by putting a subpattern into brackets, you can access the matches of those subpatterns in the replacement string. The first group (defined by the first opening round bracket) is accessed by $1, the second by $2. So in this basic example just replace with the second group and as second with the first group, that way you changed the order of your submatches.

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

Sidebar

Related Questions

I have an Excel file with a large set of VBA code. There are
I have a large number of Excel files. These files I want to add
We currently have an Excel spreadsheet containing a large amount of VBA code. The
It should be a quickie to VBA/Excel experts. I have a large 60 to
I have a rather large list of data that contains 5 properties per element.
I have large batches of XHTML files that are manually updated. During the review
I have large video files (~100GB) that are local on my machine. I have
In my application I have large area (≈5000x5000pts) and I must allow user to
I'm developing a website in PHP and I have large JS files that I
I am currently involved in porting a large and complicated VBA application to .NET

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.