Macro Fails When Data Is Filtered?
Mar 14, 2014
I have a macro that sends a sheet via email when the engineer has completed it and clicks a button. I added a filter to some of the results to remove blank lines and now the macro will not work. The problem is that if I remove the filter so that the macro does work, I end up with blank lines again.
View 4 Replies
ADVERTISEMENT
Oct 18, 2013
I have been working on a macro that compares a existing list of data to an updated list of data and then either moves any data not on the new list over to a completed tab (followed by deleting the record on the existing sheet), and then adds any items not on the existing sheet, but which appear on the new list, to the existing list.
I have come across a stumbling block, i have managed to identify on the existing list the rows of data that have been removed from the new list and therefore need to be moved over to the completed tab, but when i select the data it selects the header row aswell (which will always remain the same row). Obviously this then pastes the header row aswell, and also i can't seem to get it to paste in the new sheet to the next available row (i.e this will be used daily and i don't won't to overwrite the infor already in the completed tab). the next issue i have is then when i go back to existing sheet to delete the data i just copied across, as the header was initially select this also gets deleted.
The code below, is the complete code, including filtering, copying some forumals etc. The area i am getting stuck on is highlighted in red:
Sub Update()
Dim bottomrow As Long
Dim My_Range As Range
bottomrow = Cells(Rows.Count, "C").End(xlUp).Row
Set My_Range = Range("A1:Y" & bottomrow)
[Code] .....
View 6 Replies
View Related
Jan 11, 2007
I have a spreadsheet that is made up of single line items with sub-totals at various points going down the sheet (ie the spreadsheet is split into sections)
Each section is about 100 rows long and 40 columns wide, 10 of which are sub-totals, all using the same formula from that i enter in column A.
As i add new sections i have recorded a simple macro that copies the active cell (ie A15 for example). It then pastes into D15, F15, H15, N15, X15 and then returns to A15.
I have linked this up to ctrl X for ease of running.
I have around 500 section totals to "ctrl X", per spreadsheet and 10 spreadsheets to do in total. I have firstly filtered all the line items (rows) out to leave me just the sub-totals to [ctrl x] [arrow down] [ctrl x] [arrow down] [ctrl x] etc etc etc....
Is there anyway to automate this process, i have tried recording another macro of me [ctrl x] [arrow down] about 30 times, but when i run it, it pastes on the hidden rows, not just on what you see on the screen. Is there a bit of code i can enter so it only sees what is visible.??
View 9 Replies
View Related
Sep 26, 2007
I have written a macro that uses the goalseek function over an entire column. It works and is a happy macro. the only problem with it that I see is that it currently cannot work through a filtered list. Say, for instance, you have a column(a) that adds column(b) + column(c). Lets say that there's 10,000 rows and of those, 8,000 have a value over 10. You apply a filter and view the other 2,000 rows with values less than 10. If you run the macro in its current state you'd apply the results to all 10,000 lines - but I wish to do it only over the remaining 2,000.
I'm certain that some variation of .SpecialCells(xlCellTypeVisible) will be used but I cannot determine where. Here's my code.
Sub TryMe()
'set the goalseek area
answer = MsgBox("Please note that this macro only works on consecutive cells." & _
vbNewLine & "It will NOT work on a filtered list." & vbNewLine & vbNewLine & _
"Continue?", vbYesNo)
If answer = vbNo Then
Exit Sub
End If
restart:
With Application
On Error Resume Next
Application.DisplayAlerts = False ..............
View 5 Replies
View Related
Aug 3, 2013
my requirement is as follows. I have a school data sheet(data sheet) and i have to filter data based on each school id.I need to pass school id in a different excel sheet(input sheet). So if the school id matches then i have to copy the entire data for tht school and move to to a new sheet.
Input sheet
schoolid
211
321
Data Sheet
Emp No Surname last name schoolid
1 marian chin 211
3 luke mar 211
5 uyure tgt d 321
7 fdsfd fdsfsd 333
so whn the macro is run it should filter for 211 and 321 and move these three rows from data sheet to new output sheet.
View 1 Replies
View Related
Jun 18, 2009
if i run my macro that saves a sheet as a certain name and then prints it, it works, but if i run my macro and the file already exists it asks me to overwrite it. If i select yes it prints it and carrys on with the rest of the macro, (good). If i select no the macro fails. How can i get it so if i hit no, it runs the rest of the macro after the print command?
View 2 Replies
View Related
Nov 23, 2006
How can I let the Sub carry on to next instruction if Macro1 fails?
Private Sub Workbook_Open()
Call Macro1
' If Macro1 Fails go to next macro
Call Macro2
'If Macro2 Fails go to next macro
Call Macro3
'If Macro2 Fails go to next macro
Call Macro4
End Sub
View 9 Replies
View Related
Sep 25, 2007
I have a workbook which I need to give shared access.
The workbook has macros which make sheets visible and VeryHidden and also give certain sheets protection. Also a filter runs on one sheet.
When I give the workbook shared access, the macros error?
how I can give me workbook shared access but still allow the macros to hide/unhide sheets, filter and protect worksheets?
View 4 Replies
View Related
May 29, 2008
I have a workbook with macros that run on my laptop, but when I email the workbook to another user and the macro is executed I get a subscript out of range message?
Both Excel versions are the same.
Environments are the same.?
View 4 Replies
View Related
Mar 11, 2008
I have used the following piece of code to stop error checking in my excel spreadsheet:
Option Explicit
Private Sub Workbook_Open()
' Application.ErrorCheckingOptions.BackgroundChecking = False
End Sub
The problem is - works fine on my computer, but when distributed on the server the folloeing error is returned:
Run-time error '438':
Object doesn 't support this property or method
View 9 Replies
View Related
Jul 9, 2014
An external data web query points to a web site that offers a foreign exchange rate calculator. In my browser, I selected the specific currency pair I need and used the resulting url in the web query. The "New Web Query" pane resolves the url correctly and allows me to select the table data I want (the little yellow arrow turns to a green check mark). However, when I hit "Import" and select the target cell, the only data returned is the parameters from the url and an error msg (This web query returned no data...). How do I get the query to pass the parameters to the website correctly?
View 3 Replies
View Related
Aug 19, 2013
Is it possible to copy data that has been filtered on one tab into filtered data on another tab? I've attached an example, i'm trying to copy the values from column C on the 'From' tab to column D on the 'To' tab. I think the data is always going to be an exact fit in terms of the number of cells copied from and to.
View 1 Replies
View Related
Feb 21, 2007
I have a protected worksheet containing an SQL query. I have two cells on the worksheet unlocked so that users can enter fresh parameters to feed the query.
Because I have to use MS Query to interrogate our SQL server (current IT decree), the query won't support parameters directly when the query cannot be represented graphically - so I have to manually edit the sql command text and then refresh the query - or at least that was why I wrote the code below
The problem: My macro won't unprotect the sheet before it calls the SQL.it therefore won't update the sheet to detail the DSN, command text and number of parameters (latter should be 0) - info just used to verify queryit won't run the query / return the data as the sheet is still protected Comment: I have had to remove sheet protection in order to allow the sql to execute and return data. If protection is removed, the query does execute and return data ( changes in the "parameter" cell contents do cause the query to be correctly modified)
I could comment out the debug info but the query still doesn't return data if the sheet is protected.
Activesheet And worksheets(ndx) where ndx has been defined As ActiveSheet.Name
I apologise If my post Is difficult To follow - especially the code.
Sub AgedStockParameters()
nmb = ActiveWorkbook.Name
ndx = ActiveSheet.Name
Workbooks(nmb).Activate
Worksheets(ndx).Activate
ActiveSheet.Range("A1").Select
WkshtQryCon = Workbooks(nmb).Worksheets(ndx).QueryTables(1).Connection
ActiveCell.Value = WkshtQryCon
Range("A2").Select
WkshtQryFld = Workbooks(nmb).Worksheets(ndx).QueryTables(1).CommandText
ActiveCell.Value = WkshtQryFld.......................
View 2 Replies
View Related
Jan 3, 2014
I have a master data sheet with raw data in 19 columns and a variable amount of rows per week, but usually 50k+
The data contains entries from different Countries, and this I need to split up per country into different sheets.
Naming the different sheets with Country code like US, DK, UK, PL, etc...
Below code does that almost perfectly.
Only thing is that when there is no more data to split up, it creates the last sheet called "SheetXX" and since it can't name the sheet "nothing", I just get an error - Run-time error 1004 Method 'Name' of object'_worksheet' failed with the possibility to END or DEBUG. When going into DEBUG this line is highlighted. (wsNew.Name = c.Value)
I can just hit END and then proceed running my remaining macros, but I would prefer it not giving me an error in the first place. (My end goal is that all my macros (10ea) are run by the click of one button, and that is currently not possible, when this gives me an error).
I have tried the "Application.DisplayAlerts = False" without any luck, and also "On Error resume Next", maybe I have used it incorrectly. Do I have to search for a different way to split the data..??
VB:
Sub Split_data_pr_Country()
Dim ws1 As Worksheet
Dim wsNew As Worksheet
Dim rng As Range
Dim r As Integer
Dim c As Range
Set ws1 = sheets("Template")
[Code] .....
View 9 Replies
View Related
May 17, 2008
I cannot figure out how to get my error handler to work, or actually, not work. It seems to work fine when there is an error, but the code still gets read even when there was not an error. Basically, I am trying to open a file, which may or may not be there. When it is not there I want a message to pop up informing the user. However, when the file is there and it opens, the error handler still gives the message box. Any ideas what I am doing wrong?
Private Sub btnOK_Click()
Application. ScreenUpdating = False
Dim LCSfile As String
LCSfile = frmSelectFile.Listbox1.Value
On Error Goto ErrHandler
Workbooks.Open Filename:=sPath & sDate & "" & LCSfile & "QUANT.CSV"
ErrHandler:
MsgBox ("File is not quantitated. Please select another file.")
Application.ScreenUpdating = True
End Sub
View 2 Replies
View Related
Oct 1, 2009
I'm working on trying to maintain an inventory management sheet where i basically enter all the spare parts issued to vehicles. Now there are more than 700 parts dat form the components of a vehicle, so i decided to split this list into 12 spare groups(Gear, Engine, Body, Axle, etc etc..) and then based on wotever spare group being selected my sheet wud pull dat specific spare group list.
Since i've worked with indirect function before i thought this was a piece of cake!
However when i actually sat working on getting my sheet together i realised its not gonna be dat easy! Basically my spare group lists are a work in progress and so new items would/may be added to these lists as we start working on this sheet. So i decided to make them dynamic by using the offset function. But list validation fails when i use Indirect function on dynamic ranges!
View 2 Replies
View Related
Oct 27, 2013
I've set up a Named Range that refers to an array of constants, e.g. MyRange ={1,2,3,4,5}. This appears to be fine since I can output the named range to a range of cells in a row (e.g. A1:E1) and see 1,2,3,4,5 (one value in each column).
I'd like to use MyRange as the source for a Data Validation list in a cell.
Normally data validation list sources must be vertical, so I've set MyRange =TRANSPOSE({1,2,3,4,5}). This appears to be fine since I can output the named range to a range of cells in a column (e.g. A1:A5) and see 1,2,3,4,5 (one value in each row).
When I set MyRange as the source for data validation however, it resolves to an error.
why this setup doesn't work?
Workbook detailing the problem attached. Attachment 273788 NamedRangeDataValidationArrayConstansts.xlsx
View 3 Replies
View Related
Sep 6, 2012
I've about 10 pivot tables in Excel that are populated via an External Query link to Access. In each case I have pre-written views with all the columns I need so that the query can just pick them up. Nine of the ten queries work perfectly, but one doesn't - reporting "Too Few Parameters - Expected 1" when I try and click on the "Return Data to Excel" in the import wizard.
I can see the column headers in Excel to select; so I'm assuming that it can parse the SQL but no results are being returned. Just to confirm though - results are returned (>8000 of them) in Access.
SQL code below:
Code:
SELECT z.pathdurationhours AS PathHours, Count(z.pathdurationhours) AS Paths,
Count(z.pathdurationhours)/(select count(*) from (select [activity date],
[conversion ID], count(*) from tbl_dfa_p2cdata group by [activity date], [conversion ID]) ) AS PCT
FROM (SELECT a.[activity date], a.[conversion ID], val( max(a.[interaction time])-min(a.[interaction time]) )
*24 AS PathDurationHours FROM tbl_dfa_P2CData AS a WHERE a.[interaction time]
"" GROUP BY a.[activity date], a.[conversion ID]) AS z
GROUP BY z.pathdurationhours;
View 2 Replies
View Related
Feb 6, 2009
I'm in the process of continuing to build this babe (very slowly, as I have limited programming knowledge), and I wondered if there was a way to modify this code to make it refresh the data page if a server's page fails to load.
Part of my code is something like this, the first part being just the pseudo log on script.
Especially when there are over 50 pages to grab, the chances of one of the pages failing to load is VERY high, and this macro stops at the "Refreshbackground=False" command.
Is there a way to trigger a "refresh" once it fails?
View 10 Replies
View Related
Aug 23, 2012
I've been using a macro successfully for the last couple of years, but this morning when I went to use it, it decided to fail. I have a workbook which contains various spreadsheets. The macro that has failed performs the following tasks:
1. It copies a list of email addresss from an external workbook to a sheet in the current workbook (still works)
2. It copies the referral sheet I want to send to a new file, and saves it with an appropriate filename to an appropriate folder (still works)
3. The macro then creates an email with a standard subject line, attaches the new worksheet and emails it to each of the addresses as above (broken)
The error message is from Microsoft Visual Basic. "Run-time error '1004': Mail system failure. Check your mail installation."
I'm guessing there is a setting somewhere in Excel that has changed as part of an update.
I've been through a number of the options in the developer menu to remove any obvious restrictions (& reopened excel afterwards), but so far it hasn't resolved the problem.
For what it's worth, here is the macro code.
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Run "PullInSheet1"
Dim oldbook As String
[Code] .......
In case you're wondering about the pullinsheet code, I'll add it below - but I probably grabbed it from this forum a couple of years ago (like some of the above) & just made some changes.
Code:
Sub PullInSheet1()
Dim AreaAddress As String
'''''' Sheet11.UsedRange.Clear
Dim ClRange As String
ClRange = "= 'L:ADMINEMPLOY SERVICES" _
[Code] ........
There are a couple of things I've wanted to do to improve the macro, but I couldn't justify the need to spend time working it out (since writing spreadsheets isn't really my job). Since it's broken at the moment, I can...
1. I'd like to create a subject line that reflects the name of the person being referred. For some reason though, anything other than text in the cell reference caused an error for me. eg, I tried using concatenate to create my subject line, but it didn't work.
2. I'd like the copied sheet to contain all of the formatting of the original sheet. Presumably there is a paste option that will do this and I just picked the wrong one.
The mailsystem we use is Groupwise 8. I couldn't find any settings in that program that have been changed, or that I could change.
I should change the extension from xls to xlsx in the code since I'm using Excel 2010 (but changing it doesn't fix the problem).
View 4 Replies
View Related
Oct 3, 2008
Can't quite figure out how to do this. I'm looking to create a macro that will delete every other row of a filtered set of data. for example, if these are the filtered rows:
row 21
row 22 delete
row 50
row 51 delete
row 58
row 59 delete.
... and so forth down to the bottom of the filter. I cant seem to record the macro using a relative reference with the filtered data.
View 3 Replies
View Related
Sep 16, 2009
I'm trying to write a macro that goes through every value in a filtered list.
Specifically, I'd like the macro to select the first value in the filter. Perform the operation. Select the second value in the filter. Perform the operation. Select the third value in the filter. Perform the operation. Etc...
View 9 Replies
View Related
Jun 1, 2011
I have a 5000 line table I am filtering by a few columns, and I'd like to calculate an exponential trendline value.
=INDEX(LINEST(LN(R1059:R1167),W1059:W1167),1)
But I actually don't want all the values from R1059 to R1167 - I want to select only the displayed values (R1059, R1068, R1077, etc). Is there a way to select only display values to use in a formula? The problem is it would be a lot of manual work to select them all - there are 50 or so instances I would have to select 13 manual values.
I am using Excel 2007 on XP.
View 8 Replies
View Related
Oct 28, 2011
I have a large worksheet, with approx 15 columns of data, which is a straight data dump from a very old sales reporting system - so the whole thing is a mess.
As such, I auto filter the report, and select certain criteria from various columns, which leaves me with just the data I wish to see on screen.
What I then need to do is copy across any visible values (after this filtering) from Column C (missing out row 1, which is headings), into the same row in Column E.
At the moment, this is a manual process, because if you highlight the entire selection of codes in column C, then paste in Column E, due to the filtering, the paste puts the values in all the wrong places.
Is there a way around this - or a macro which will copy the values to the same row but in Column E?
View 4 Replies
View Related
Nov 6, 2012
I have an issue with trying to write a macro to apply a filter and then delete all lines.
Within the macro I copy and paste one sheet to a new one, and Paste Special Values over all formulas, leaving me with a column that has some figures and some "#N/A".
i.e.
13.75
12.00
#N/A
14.00
So I need to do something in the macro that then applies a filter on this column and deletes off all the #n/a results.
This table has a number of columns not just this one so it is the full rows that need removing.
I see on other posts that using a range.specialcells clause could work, but i'm not too sure exactly on how to apply this.
View 1 Replies
View Related
Apr 22, 2009
This code was provided this forum. It is so close to what I need. The only difference is that I need the copied lines inserted.
Actually, I needed Destination to pick EndT2 (on Sheet2), then select one row down from it and then insert what was copied... -R-
Sub CopyFilteredRangeNoHeaders()
Dim rTable As Range
Set rTable = Sheet1. AutoFilter.Range
Set rTable = rTable.Resize(rTable.Rows.Count - 1)
'Move new range down to start at the fisrt data row.
Set rTable = rTable.Offset(1)
rTable.Copy Destination:=Range("EndT2")
View 9 Replies
View Related
Jan 2, 2014
I have been trying to find a way to sum up/only show the filtered data in a sheet.
i want to beable to filter the data by year and then only show sum up the data shown not
the entire column, is there a formula that will let me do this?
View 3 Replies
View Related
Apr 7, 2014
I have a pivot table with multiple supervisors and emloyees, I need to be able to find the average of a supervisors department and compare it with an employee with the employee seeing everyone else's data.
I don't have access to the original data that drives this pivot table. Is there some way I can use a calculated field to contain the average performance of all the employees under this particular supervisor?
View 3 Replies
View Related
Mar 23, 2014
In Worksheet A I have hundreds of Rows... Column 2 has a Type in it and not all rows will have a type and then there are various data elements in column 3, 4, 5 and 6
What I would like to do is in a worksheet B have a formula on each of the cells on a row that would look to worksheet A and would find the first row to match the type value in column 2. I would then want to lookup the value of column 3, and 4, and 5 and 6. Then in worksheet B, the next row the formulas in the cells that would also match type and would continue with the NEXT row in worksheet A that matched the type and again retrieve the appropriate cells. It would continue stepping through the rows of worksheet A until I had all of the now displayed in worksheet B
Basically I want to built a subset of worksheet A into worksheet B using the value of the Type column in worksheet A.
I suspect I am going to need to use multiple forumulas nested together in some way to achieve this.
View 3 Replies
View Related
Apr 21, 2013
Is it possible to filter a top * for already filtered data. E.g, i have sales people each having their total sales per month , what im trying to achieve is when i filter for only 1 person i want to get the top 10 sales months for that person.
View 2 Replies
View Related