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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:00:45+00:00 2026-05-25T15:00:45+00:00

well I have lots of string manipulations like 1st one ActiveSheet.Cells(i, B).Value = Replace(ActiveSheet.Cells(i,

  • 0

well I have lots of string manipulations like

1st one
ActiveSheet.Cells(i, "B").Value = Replace(ActiveSheet.Cells(i, "B").Value, ",", " ")
ActiveSheet.Cells(i, "B").Value = Replace(ActiveSheet.Cells(i, "B").Value, "/", " ")
ActiveSheet.Cells(i, "B").Value = Replace(ActiveSheet.Cells(i, "B").Value, "&", " ")
ActiveSheet.Cells(i, "B").Value = Replace(ActiveSheet.Cells(i, "B").Value, "(", " ")
2nd one
store=ActiveSheet.Cells(i, "B").Value
store= Replace(store, "/", " ")
store = Replace(store, "&", " ")
store = Replace(store, "(", " ")

and some trim operations and sometimes finding string length and sometimes comparison.

I have to do looping for cells 1 to 4000. The question is storing the cell value in string and accessing is better and faster? or writing the activesheet cell value in the macro is itself faster?

store = activesheet.cells(i,"B").value and use store everywhere 
or write activesheet.cells(i,"B").value everywhere?

Which is better which is more optimized I was kinda thinking if we mention the cell value it has to go to sheet and get it back but if we store it in variable then it might be faster. I just need to know which is better ?

  • 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-25T15:00:46+00:00Added an answer on May 25, 2026 at 3:00 pm

    Accessing Excel is slow. Storing things you’ll access more than twice in a variable will always be faster, and dumping a range of cells (one call to Excel) into a variant array is even better.

    Remember, Excel and VBA are not the same. It’s like two guys in the same flat but different rooms. Everytime you access Excel, VBA has to knock on Excel’s door.

    Update:
    The above is general advice for all code. Concerning the particular code above and what you are doing, it might actually be faster to use Excel’s search and replace functionality on the range like so:

    Sub test()
    
    Application.ScreenUpdating = False
    With Range("B1:B4000")
        .Replace what:="(", replacement:=" ", LookAt:=xlPart, SearchOrder _
        :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    
        .Replace what:="&", replacement:=" ", LookAt:=xlPart, SearchOrder _
        :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    
        .Replace what:="/", replacement:=" ", LookAt:=xlPart, SearchOrder _
        :=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
    End With
    Application.ScreenUpdating = True
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty complex but well-formatted HTML string with lots of links in
Well,i have a weird question to ask,sometimes when designing a form and using lots
Well I can't figure this one out... I have this Wordpress I use as
I have lots of unrelated named things that I'd like to do quick searches
Well i have a gridview where i have defined the columns on my own
Well i have a transparent div or the background is set to transparent :)
well i have most probably an extremly stupid problem but could not figure it
Well i have a control thats placed in a usercontrol and it exposes a
Well I have this code in my Managed C++/Cli in Visual Studio 2008, I
Well I have to convert # j = 0 # x = a[j+k] #

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.