Copying of data skipping blanks - excel

Good Day, can somebody please help me. I have 2 spreadsheets, the second spreadsheet has got the copied cells exactly like the first one. But my problem is that on the first spreadsheet I have blank rows as the invoices are being put in date order and not invoices on every day. The second sheet I use for Vat purposes and want my selection there to be in list form in order to only print 1 page for bookkeeper. Where I have invoices for eg. on 10th, 15th and 20th on first spreadsheet "what formula can I use for the 3 invoices to appear in the second spreadsheet eg. in row 1,2,3 one right underneath the other one.
I have done VBA 20 years ago and came right with everything except this I can not figure out for the life of me. Thanks in advance to anybody that can help me with this.

highlight, press F5, click "special" select either "constants" or "formulas" depending on if it is hardcoded or formulaic data, then hit ok. this will leave all blank cells out of the selection, then copy paste as normal to the other workbook. if your doing it in vba this is all available in the object model as
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
UPDATE: I forgot about the bug (design flaw?) in excel that makes it error out when you try to copy a non-rectangular selection. See here (the article is older but appears to apply to 2013):
http://support.microsoft.com/kb/100715
I believe there are macros available on the internet to deal with this problem, one of them is here
http://www.extendoffice.com/documents/excel/799-excel-copy-multiple-selections.html
A quick fix would be to take the inverse approach: use the "special" selection to select blanks, and then delete them. then select a rectangle around the remaining cells.
the VBA call to select blanks is
Selection.SpecialCells(xlCellTypeBlanks, 23).Select

Related

Excel VBA: Insert rows and paste values

I will preface this by stating that I would not be surprised if the answer is floating around out somewhere and I just haven't seen it, so if this is truly a duplicate, I apologize. Here is the situation I'm facing, though.
I use Excel at work to help keep track of patients and their statuses as far as clearance for procedures at my unit. I have 5 sheets open: Tracker, Removed, Added, Old, New, and Compare. Every morning, I generate a report of the updated schedule. I take what is in "New" and copy it over to "Old". I take what was generated and copy it to "New". In "Removed" and "Added", there are formulas that populate fields based on if a patient exists in Old but not New (removed) or vice versa (added). If the patient has been added, I need to insert them into Tracker at the appropriate location (e.g. if a patient was added for an appointment on 9/3 at 2:45 pm, I would need to add them between 9/2 2:30 pm and 9/6 7:30 am). I can do this one of two ways currently: Right-click on the appropriate space, Insert Row above, and then go over and copy/paste the values, or I can copy the row first (which is a formula), right-click and Insert Copied Cells which pastes the formula, right-click again and select 'Paste values'. Either way, it's two steps. It boggles me that Excel does not have an 'Insert Copied Cells special' where it will just to the values.
I understand that VBA may be used in this case, but I have no idea how I would go about doing so. Every example I have now seems to indicate that a specific row must be named, but I do not have that luxury. It literally needs to go above the selected row. Is there a way this can be done, or am I doomed to just do the dual steps forever? Or am I just overcomplicating things in general?

How to copy and paste formatting from the bottom cell of a table to the next cell below it?

I have a macro that cuts cells out of a table if the entries' date is > 2 weeks old. It then Deletes these cells. However, this causes my formatted area for data entry to shorten each time, so I am trying to find a way to fix this. My idea was to write a piece to copy the formatting from the last formatted row and paste it directly below it, but I am not sure how to go about doing this in VBA. I am newer to VBA and was wondering if anyone knew how to help? Thank you!
It sounds like your goal is to basically have your data entry table ALSO be your summary table, hence wiping out all entries greater than 2 weeks old. This seems like it will end up backfiring on you at some point - for example, what if you wanted to pull a report on everything you entered over the last year?
A better route would seem to be to have a single data entry sheet where you keep EVERYTHING and then a summary display that actively just pulls the data from the last two weeks. For that, you could use VBA to filter your data set based upon the date and then copy the information over to the new sheet (just do it once manually using the filter tool from the Home tab on the ribbon, while recording your actions to a new macro, and you should be able to clean it up pretty easily).
If you MUST edit in place, and presuming you don't mind it being sorted by date, record a macro where you select your full formatted range, turn on filtering, filter by your date column, delete the contents (just use the delete key) of the cells you want to wipe out, and then sort by date on the rest.
The cause of your problem is that in using the range.delete command you are removing the cell from existence (and hence shrinking your formatted range) - you just want to wipe out the contents and then move all your data up to fill the blank space.
good luck!

Excel formula changes when external source is updated

Every row in the Q column computes the quantity of prime numbers(up to 9) in the 15 numbers in the same row. These 15 ones come from an external txt file.
Then, when I update the txt and refresh it in Excel, the formula on the last row changes so that it does not work the expected way.
It's hard to explain so here`s a picture:
Can anyone help me with this one?
Click on Properties under Data tab
Click on "Overwrite existing cells with new data, clear unused cells"

Macro: Transposing issue

Wonder if someone can help me with this one
Using VBA, I have set up a macro which starts by transposing a pivot table into another sheet then touches up the data automatically into a tidy little list for users to set up in a database later.
Now after building it first time for the pivot table it worked a dream and gave me the results I wanted but whenever I update the pivot table and it changes its length, I began to start having problems. Hopefully these screenshots will help:
You dont need to know the info on there but what the macro is expected to do here is transpose the entire pivot which can be done by either double clicking the cross section of the grand totals or right clicking on the cell and select show details of everything. (Highlighted in yellow)
As it stands at the moment the code for getting that cell is set to is:
Range("AA65").Select
Selection.ShowDetail = True
This is where I realized that it is fixed (At the moment to the place highlighted in red) and I have no idea how I can resolve it by making the macro adapt to varying lengths of the pivot table so that it can transpose all of the contents within it. If it helps, the grand total will always be on that particular row its just the column where it ends up that changes.
Is there a way for me to create a code where I can always pick up that Grand Total cell in the pivot no matter how many columns it stretches out to?
Thank you for reading and I hope to get feedback soon :)
Kind Regards
Zoe
for instance
With ActiveSheet.PivotTables(1).TableRange1
.Cells(.Cells.Count).ShowDetail = True
End With

Copy and Paste a Row from Sheet1 Containing "YES" in Cell J to Sheet4 in Excel 2007

I have been looking for an answer to this issue for several days by using google and various Excel troubleshooting sites. Unfortunately, I am 100% unfamiliar with Macros in Excel and my training isn't until April (I am signed up though!). Becuase I just don't understand the programming, I am having a hard time "fixing" solutions online to meet my needs. I really need to have this specifically laid out for my situation.
I have a spreadsheet containing Sheet1 and Sheet4. Sheet1 has data in columns A-L and can have unlimited rows. When the value "YES" is entered in column J, I would like the macro to copy and paste that whole row into Sheet 4 in the next empty row.
Could anyone help? This project must be completed by Monday, March 19. Thank you!
If you are 100% unfamiliar with Macro, I do not recommend you start off by fixing solutions online.
You can try record Macro in order to generate some code. One way could be:
Filter on column J for "YES" only.
Copy those rows to Sheet4.
And then you can make modification to the code. (I think they are easy enough to understand). It will help if you can post the codes you have tried.
If you want to trigger this action only when a button is pressed, you can simply create that button and assign it to your macro (Sub).
If you want this to happen automatically, you will have to try the Worksheet_Change Event mentioned by Siddharth

Resources