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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:44:52+00:00 2026-06-15T06:44:52+00:00

I am currently mapping column names to variables in excel and then using the

  • 0

I am currently mapping column names to variables in excel and then using the variables in my formula for new rows, here is an example example;

Dim posType as String

Cells.Find(What:="PositionType", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False).Activate


posType = ActiveCell.EntireColumn.Address(False, False)
posType = Left(posType, InStr(1, posType, ":") - 1)


Sheets("sheet1").Range("A1").Select

ActiveCell.End(xlToRight).Select

ActiveCell.Offset(0, 1).Select
Selection.FormulaR1C1 = "PTH Size"

 ' PTH SIZE
Cells.Find(What:="PTH SIZE", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False, SearchFormat:=False).Activate
    ActiveCell.Offset(1, 0).Select

Selection.Formula = _
  "=IF(" & posType & "2=""PTH""," & settlementDateQuantity & "2,0)"

pthSize = ActiveCell.EntireColumn.Address(False, False)
pthSize = Left(pthSize, InStr(1, pthSize, ":") - 1)
r = ActiveCell.Row

With Worksheets("sheet1").Range(pthSize & r)
    .AutoFill Destination:=Range(pthSize & r & ":" & pthSize & lastrow&)
End With

The file I import can change from day to day in the order of their columns but they allays use the same names, currently I am using the find method to get the column then saving the letter to a string and using the reference in my formula however the process of using find and mapping 100 columns is pretty slow…

I have been trying to come up with a better method to do this but cant think of anything faster, could anyone help me out by suggesting a possibly faster way of doing this?

I am also considering moving my project across to EXCEL DNA, does anyone know how much faster it would make my macros run?

Thanks

  • 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-15T06:44:53+00:00Added an answer on June 15, 2026 at 6:44 am

    You are selecting and moving around a workbook rather than just doing the assignments this will slow down the program A LOT!!!

    I made SOME changes to move you in the right direction – Try this out:
    (NOTE: It was quick and dirty, so I may have made a few mistakes in cell references, but it should move you in a better direction at the very least)

      Dim posType As String
      Dim SelectedCell As Range
    
      Set SelectedCell = Cells.Find(What:="PositionType", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
          :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
          False, SearchFormat:=False)
    
      posType = Mid(SelectedCell.Address, 2, InStr(2, SelectedCell.Address, "$") - 2)
    
      Set SelectedCell = Sheets("sheet1").Range("A1").End(xlToRight).Offset(0, 1)
      SelectedCell.Value = "PTH Size"
    
       ' PTH SIZE
      Set SelectedCell = Cells.Find(What:="PTH SIZE", After:=SelectedCell, LookIn:=xlFormulas, _
      LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
          False, SearchFormat:=False).Offset(1, 0)
    
      SelectedCell.Formula = "=IF(" & posType & "2=""PTH""," & settlementDateQuantity & "2,0)"
    
    
      pthSize = Mid(SelectedCell.Address, 2, InStr(2, SelectedCell.Address, "$") - 2)
      r = SelectedCell.Row
    
      Worksheets("sheet1").Range(pthSize & r).AutoFill Destination:=Range(pthSize & r & ":" & pthSize & lastrow&)
    

    Again, note that this could still be made substantially more efficient, but this is a much more efficient way of doing things…

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

Sidebar

Related Questions

I've an entity A which has an Id and ParentId column. Currently I'm mapping
I am using this in Script Component In SSIS --> Microsoft.Office.Interop.Excel.Application objXL = new
i am currently using the following mapping to map a split entity and is
How do you get the column names from a db? Currently, I'm interacting with
I'm currently doing the following to compensate for boolean's not mapping well to radio
Currently I am using HTML files for parts of my user interface. I display
currently, I`m implementing a map App with Mono4Droid and there I`m using a WebView
Currently I'm starting a new Activity and calling finish on a current one. Is
I'm currently using NHibernate as my data access layer, using Fluent NHibernate to create
I'm new to using NHibernate/Fluent NHibernate and am trying to figure out how to

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.