Programming

Programming questions? Ask a programmer for answers ASAP

Ask a Computer Expert,
Get an Answer ASAP!

I have a excel VBA question: How can you make this code more…

Customer Question
I have a excel VBA...
I have a excel VBA question: How can you make this code more efficient? I have it repeating twice but im sure you could combine the two IFs into one'puts the Open orders below the data
Dim LastRow, NewLast, MovedCount As IntegerLastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row 'Find last Row
NewLast = LastRow + 1 'NewLast tracks the new last row as rows are copied and pasted at the end
MovedCount = 0
For I = 2 To LastRow
If Left(Cells(I, 4), 1) = "O" Then 'Copy the row, increment NewLast and paste at the bottom.
Rows(I).Cut
'LastRow = LastRow - 1
Cells(NewLast + 5, 1).Select
ActiveSheet.Paste
Rows(I).Delete
I = I - 1 'Since we deleted the row, we must decrement i
MovedCount = MovedCount + 1 'Keeps track of number of rows moved so as not to overshoot the original last line
End If
If I + MovedCount = LastRow Then Exit For 'Exit For loop if we reached the original last line of the file
Next I
'puts the Open orders below the data
Dim LastRow2, NewLast2, MovedCount2 As IntegerLastRow2 = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row 'Find last Row
NewLast2 = LastRow2 + 1 'NewLast tracks the new last row as rows are copied and pasted at the end
MovedCount2 = 0
For N = 2 To LastRow
If Left(Cells(N, 1), 8) = "40-00004" Then 'Copy the row, increment NewLast and paste at the bottom.
Rows(N).Cut
'LastRow = LastRow - 1
Cells(NewLast2, 1).Select
ActiveSheet.Paste
Rows(N).Delete
N = N - 1 'Since we deleted the row, we must decrement i
MovedCount2 = MovedCount2 + 1 'Keeps track of number of rows moved so as not to overshoot the original last line
End If
If N + MovedCount2 = LastRow2 Then Exit For 'Exit For loop if we reached the original last line of the file
Next N
Submitted: 8 months ago.Category: Programming
Show More
Show Less
Ask Your Own Programming Question
Answered in 39 minutes by:
9/29/2017
Programmer: The-PC-Guy, Software Engineer replied 8 months ago
The-PC-Guy
The-PC-Guy, Software Engineer
Category: Programming
Satisfied Customers: 2,192
Experience: Extensive Knowledge in PHP, MYSQL, CSS & Javascript
Verified

Thanks for using JustAnswer. My name is***** will do whatever I can to answer your question and will be back in a moment with my reply.

Ask Your Own Programming Question
Programmer: The-PC-Guy, Software Engineer replied 8 months ago

what exactly is it you are trying to do?

Ask Your Own Programming Question
Customer reply replied 8 months ago
I have sales data that needs to not include Open orders (anything starting with O in column) AND also any remaining orders that start with 40-00004 in the first column. The code that i have already works, im just trying to find ways to make the macro run quicker. So wondering how we can combine these two IF statements into one. See picture for context.
Programmer: The-PC-Guy, Software Engineer replied 8 months ago

most efficient way is to use arrays. If you do all your reads first into an array then do all of the writes afterwords. Read / Write repeating always takes longer.

Arrays don't preserve formatting though, unless source / destination has same formatting to begin with

The only other possibility would be to filter the data, then copy/delete filtered data

Ask Your Own Programming Question
Customer reply replied 8 months ago
Yeah the data is already formatted. I would be interested in seeing what you do with an array, im not very familiar with so it would be interesting to learn
Programmer: The-PC-Guy, Software Engineer replied 8 months ago

what is your budget, I cannot possibly do it for the amount you requested.

Ask Your Own Programming Question
Programmer: The-PC-Guy, Software Engineer replied 8 months ago

sent additional service offer in case your are interested.

Ask Your Own Programming Question
Customer reply replied 8 months ago
absolutely not. You are overcharging for sure. You once quoted me 75$ for a much bigger project than the one i just asked help for
Programmer: The-PC-Guy, Software Engineer replied 8 months ago

good luck then

Ask Your Own Programming Question
Customer reply replied 8 months ago
Yeah i'll take my question to stack overflow for $0
Was this answer helpful?

How JustAnswer works

step-image
Describe your issueThe assistant will guide you
step-image
Chat 1:1 with a programmerLicensed Experts are available 24/7
step-image
100% satisfaction guaranteeGet all the answers you need
Ask The-PC-Guy Your Own Question
The-PC-Guy
The-PC-Guy
The-PC-Guy, Software Engineer
Category: Programming
Satisfied Customers: 2,192
2,192 Satisfied Customers
Experience: Extensive Knowledge in PHP, MYSQL, CSS & Javascript

The-PC-Guy is online now

A new question is answered every 9 seconds

How JustAnswer works:

  • Ask an ExpertExperts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional AnswerVia email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction GuaranteeRate the answer you receive.

JustAnswer in the News:

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.

What Customers are Saying:

My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed.

One Happy CustomerNew York

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Mary C.Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

AlexLos Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

GPHesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

JustinKernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

EstherWoodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

RobinElkton, Maryland

< Previous | Next >

Meet the Experts:

ATLPROG

ATLPROG

Computer Software Engineer

7,677 satisfied customers

MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML

LogicPro

LogicPro

Computer Software Engineer

7,175 satisfied customers

Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.

unvadim

unvadim

Computer Software Engineer

1,168 satisfied customers

Good knowledge of OOP principles. 3+ years of programming experience with Java and C++. Sun Certified Java Programmer 5.0.

lifesaver

lifesaver

Computer Software Engineer

950 satisfied customers

Several years of intensive programming and application development experience in various platforms.

ehabtutor

ehabtutor

Computer Software Engineer

936 satisfied customers

Bachelor of computer science, 5+ years experience in software development, software company owner

TheDoctor

TheDoctor

Software Engineer

893 satisfied customers

M.S. in Internet Information Systems

The-PC-Guy

The-PC-Guy

Software Engineer

2,192 satisfied customers

Extensive Knowledge in PHP, MYSQL, CSS & Javascript

< Previous | Next >

Related Programming Questions
I use excel spreadsheets on our computer at home. It is an
I use excel spreadsheets on our computer at home. It is an older version and has been working well, however today when I pulled up my spreadsheets and try to save changes it closes. … read more
John Castle
John Castle
BSC in Computing Network Management and Design
78 satisfied customers
I am having trouble with this formula in excel. Not sure.
=IF(C3="9:00 to 1:00 PM","4",IF(C3="9:00 to 5:00","7.5",IF(C3="OFF","0"))) … read more
Russell H.
Russell H.
Computer Technology Consultant
Vocational, Technical or Trade Scho
789 satisfied customers
When opening an Excel file created in 2003 in Excel 2016 the
when opening an Excel file created in 2003 in Excel 2016 the columns width changed … read more
Jeevan DSouza
Jeevan DSouza
Professor
PhD
6 satisfied customers
I need help with excel 2016. I just bought it today. Trying
i need help with excel 2016 JA: When did you last update Excel? Customer: i just bought it today JA: What have you tried so far with your Excel? Customer: trying to update charts and i cannot JA: Anyt… read more
George Sibiya
George Sibiya
PhD
304 satisfied customers
Microsoft Exel 2003 not responding. English. Excel stops
Microsoft Exel 2003 not responding JA: Is there a specific language you're coding in? Customer: english JA: What's your objective? How can we solve this for you? Customer: excel stops working, not res… read more
Jason Jones
Jason Jones
AAS Information Technology
6,324 satisfied customers
I LOST EXCEL WHEN MY COMPUTER CRASHED AND CAN NOT OPEN
I LOST EXCEL WHEN MY COMPUTER CRASHED AND CAN NOT OPEN FILES. … read more
Richard
Richard
IT Manager
IT Manager, Consultant
3,439 satisfied customers
Microsoft excel keeps closes down while i'm working on a
Microsoft excel keeps closes down while i'm working on a project … read more
Cody
Cody
Computer Science
2,376 satisfied customers
Does Excel 2016 check for punctuation? If not is there an
Does Excel 2016 check for punctuation? If not is there an app or something that might help? … read more
Michael Rademacher
Michael Rademacher
MBA
13 satisfied customers
It started out with excel not working. So I was told to
it started out with excel not working. So I was told to uninstall Microsoft 365 and reinstall it. How do I do that … read more
Jason Jones
Jason Jones
AAS Information Technology
6,324 satisfied customers
Excel Office 365. Two days ago. My excel spreadsheets have
My excel spreadsheets have an exclamation point on them. They are very slow. … read more
Richard
Richard
IT Manager
IT Manager, Consultant
3,439 satisfied customers
I need to create a permanent excel spreadsheet to calculate
Hi i need to create a permanent excel spreadsheet to calculate the buyer premium at an auction house. … read more
The-PC-Guy
The-PC-Guy
Software Engineer
2,192 satisfied customers
Its an excel specific quesion...is there a reasource for
its an excel specific quesion...is there a reasource for that? … read more
Michael Rademacher
Michael Rademacher
MBA
13 satisfied customers
This is an Excel question and relates specifically to the
This is an Excel question and relates specifically to the need for a conditional formula. The requirement is as follows:I need the recipient cell to equal the value posted to cell I165 as it appears o… read more
The-PC-Guy
The-PC-Guy
Software Engineer
2,192 satisfied customers
I can't open an excel spreadsheet in Microsaoft Office
I can't open an excel spreadsheet in Microsaoft Office Professional 2007 that I was working on this afternoon. … read more
Viet - Computer Tech
Viet - Computer Tech
Computer Technican
Bachelor\u0027s Degree
969 satisfied customers
I was working on an excel sheet, the report would not
i was working on an excel sheet, the report would not generate, downloaded Script Lab, now document is frozen … read more
Richard
Richard
IT Manager
IT Manager, Consultant
3,439 satisfied customers
I need an excel expert. Get me someone for 2016 excel
I need an excel expert JA: When did you last update Excel? Customer: get me someone for 2016 excel JA: Anything else you want the Microsoft Office Expert to know before I connect you? Customer: no… read more
Jason Jones
Jason Jones
AAS Information Technology
6,324 satisfied customers
Need help with VLOOKUP. EXcel. Excel 2013 recently. Tried
need help with VLOOKUP JA: Is there a specific language you're coding in? Customer: EXcel JA: When did you last update Excel? Customer: Excel 2013 recently JA: What have you tried so far with your Exc… read more
The-PC-Guy
The-PC-Guy
Software Engineer
2,192 satisfied customers
Lost my Excel icon on task bar. Lost my excel icon on the
lost my excel icon on the task bar. can't use excel … read more
Kamil Anwar
Kamil Anwar
IT Consultant / Systems Engineer
Bachelor\u0027s Degree
460 satisfied customers
Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Show MoreShow Less

Ask Your Question

x