[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

In Excel How do I prevent an empty cell being created when I am building a list from several sources

Posted on 2014-03-24
3
Medium Priority
?
216 Views
Last Modified: 2014-03-25
In Excel I have written code that works fine as long as the first Administration list, that is copied to build up a combined list (in the sheet Payroll nos), is populated.
If the first list is not populated and the second list is populated my macro 'pastes' the second list one cell down from the first cell (in Payroll nos) instead of in the first cell.
The result is that the final code to remove duplicates and put the results into a master list in column D leaves the master list empty.

As I said the code works perfectly well as long as the first list has some data
1-MODEL-v1.09.xlsm
0
Comment
Question by:DAVID131
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 2000 total points
ID: 39951323
First, get read of all the select statements, e.g.

Sheets("P Administration A").Select
    Range("B2:B500").Select
    Selection.Copy

Open in new window


becomes

Sheets("P Administration A").Range("B2:B500").Copy

Open in new window


That's not going to fix your macro, but it's going to make your code faster, easier to read and to maintain.

for your nextrow, after each

nextrow = Cells(Rows.Count, 1).End(xlUp).Row + 1

Open in new window


add

if nextrow=2 and len(cells(1,1))=0 then nextrow=1

Open in new window


Thomas
0
 

Author Closing Comment

by:DAVID131
ID: 39954243
Spot on Thomas works a treat
Thanks for rapid response
0
 
LVL 39

Expert Comment

by:nutsch
ID: 39954247
Glad to help.

Thomas
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question