Determining If A Worksheet Exists
Jun 11, 2009I try to do the following I get an error 'Subscript out of range'
View 3 RepliesI try to do the following I get an error 'Subscript out of range'
View 3 RepliesThe table I'm trying to query contains the beginning and end date the data is effective. The end date seems to always be either 27 or 34 (4 or 5 weeks) after the start date.
This is the table I'm trying to query:
[URL]
I want to have it query the whole history going back 2 years, and be refreshable by other users on demand.
If I put in dates that do not match up exactly with the start/end dates they have set, I get something like this:
[URL]
I've got a plan of how to approach the data extract, but how can I determine whether or not the web query found a specific table (and should therefore try a different date offset)?
i would like to know whether a worksheet exists or not... say, the worksheet name is sheet1, i need to check whether the worksheet exists... the point is, i need to delete the worksheet if it exists and execute a code... if the worksheet doesn't exist also, i need to execute the code... so im getting a little confused with this... i need something like this...
if sheet1_exists then
delete the sheet
end if
my_code.......
Does anyone have SIMPLE code for this that can be run in a normal Sub. My worksheet will always be named "Cleaned". I have seen some posts regarding Functions and other things that seem more complicated than necessary.
View 9 Replies View RelatedI have a spreadsheet with columns set up like this: RowName, Date, Value1, Value2, Value3 etc. The date is in format YYYYMMDD. What I am trying to do follows, in some sort of pseduo fashion.
View 2 Replies View RelatedHow do I delete a worksheet but ONLY if it exists, if it doesn't exist, ignore the command. I'm afraid to mess up the other code in the macro/sub, so here it is...
View 2 Replies View RelatedI have an array that opens a workbook containing close to 100 worksheets, and copies specific sheet names into there own individual workbooks. The problem I have now, is that I assume the worksheet exists in the workbook, but often times it does not Is there a way to add some sort of "catch" that will 1st verify the worksheet exists instead of my code crashing?
View 9 Replies View RelatedI have a macro that 'opens all' workbooks in the specified folder. I've copied it over, but need to only open all the wbk's if a specified worksheet exists w/in the wbk..I know there is a dim ws statement that can be used, but how do i use it w/ the current macro?
Option Explicit
Sub recTestOpenAll()
Dim x As Integer
Dim WB As String
Dim wbk As Workbook
For x = 1 To 100
WB = "G:Rule Test FilesREC " & x & ".xls"
On Error Resume Next
Set wbk = Workbooks.Open(Filename:=WB)
On Error Goto 0
If Not wbk Is Nothing Then
End If
Next
End Sub
I am writing a macro which first needs to look and see if a certain worksheet exists. If it doesn't then I want it to create it but if it does I first want it to delete the sheet then create a blank one with the same name. At trhe moment I have this but it is scrappy and doesn't work very well:
On Error Goto AddSheet
If Sheets("MONEYSHEET").Activate Then Goto Data
AddSheet:
Sheets.Add before:=Sheets("LOOKUPSHEET")
ActiveSheet.Name = "MONEYSHEET"
Data:
It also does not delete the sheet if it already exists, just edits the existing one.
I'm looking to use the value from a series of dropdowns (made via data validation lists).
Cell AM5 is a dropdown of named ranges made form a seperate sheet
Cell AO5 is a dropdown that uses '=INDIRECT(AM5) to lookup the values in the named range.
I need cell AO5's value to be used to filter rows in the current worksheet. The current problem is when i use the first dropdown in AM5 it still displays the last value, untill i use the dropdown to select a new one. This value typically will not be found and i do not want my code to execute in these cases.
how do I automatically add beside the name the colum title where it previously existed. see the attached.
View 2 Replies View RelatedI'm creating a macro to select, modify dimensions and place shapes on a excel sheet. (I'm talking about pictures insered and stocked in a specific sheet of my workbook)
When the users insert a new picture he has to set a name for each of them.
A combobox contain the choices, when an item is selected, the macro identify, size and place the corresponding picture.
But I have a bug if a shape doesn't exist when I try to select it :
Sheets("fiche de controle").Select
'select the sheet with the pictures
ActiveSheet.Shapes(Item_old).Select
'select the shapes "Item_Old"
Item_Old is a variable corresponding to the picture name.
If the user made a typo, I have a bug.
Someone knows how to test if the shapes exist to display a meesage if not ?
Or somethig to avoid this kind of bug ?
I have working data on list sheet and added data on compiled sheet.
I need to match duplicates and delete these rows from compiled sheet.
I've tried coping to the list sheet and use "Remove Duplicates", but it rids me of the data that has been processed and has fills applied.
I'm looking for a macor that can do this work for me without losing data on list sheet.
This data reaches into the thousands and I'm looking to run this off the CASE column.
I have a spreadsheet with 2 worksheets. On the first "active parts" I have a list of active part numbers and on the second "All Parts" I have all of the parts available.
I want to compare every part in the All Parts worksheet to see if the part number exists on the Active Parts sheet - if it's there, I would like it to return the value "Active" in column B in All Parts. I have a formula in column B in All Parts that seems to work for the first few, but as soon as it finds one that is active, the rest of the cells below all return "Active".
I've got a formula which makes a word "Order" (column B) meet the closest value of 35.00 (column A)
How to modify the formula so that ''Order" meets the closest value of 35.00 in the range (>=35;<39) throughout the column?
There are about 20 approximate and precise values of 35.00 in the column A which have to be met by "Order".
I've been trying to change the value comparisons and precisity (pecentage) to set up the range from 35.00 till 39.00.
but encountered a problem that "Order'' often meets two closest values of 35 till 39, often one of them is going under 35.00 e.g. 36.50; 34.00.
Consequently how to change/substitute the formula, parameters, value comparisons etc. to meet the requirements!
See the workbook attached. 13_05_det_closest_value.xlsx‎
What code can i use to determine the same rows in 2 different columns and compare the data in those two cells?
View 9 Replies View RelatedI have a document in which I am trying to determine the length of time between a start date & time and a finish date & time. The format of the time/date cells is
mm/dd/yy hh:mm:ss
Basically, I am just subtracting the first cell from the second. This works fine as long as both dates are in the same day, such as
START FINISH ELAPSED
08/20/14 23:42:22 08/20/14 23:43:59 0:01:37
However, if I have a situation such as
START FINISH
08/18/14 23:00:15 08/19/14 0:03:22
the ELAPSED cell fills with ######## with a tooltip stating that "dates and times that are negative or too large display as ######." The actual result in this example should be 1:03:07.
How do I get consistency amongst my resulting formulas?
I am trying to figure out a simple formula on determining class for students according to their achievement /grades. There are 9 classes altogether ( 7A, 7B, 7C, 7D, 7E, 7F, 7G, 7H and 7J). There are three columns for subject ( MATHS, ENGLISH, SCIENCE). So lets say the student get Grade A, A , A : The student will belong to Class 7A.
As attached.. TEST PSR.xls‎
My question is about determining whether or not a particular letter is uppercase.
I've written code that reads from a text file one character at a time. And I know that the following determines if each character is equal to the letter "a".
I am trying set up my spreadsheet so that when a number is put into one column. The next column is filled with a number that will correspond to the other number specified from a range of data.
Distance Sheet no.
55
68
93
135
186
So in the sheet No. column I want it to read the number in the Distance and put in the Corresponding sheet number.
So if:
Sheet 1 is : a distance of 1 though 20
Sheet 2 is : a distance of 20 though 40
Sheet 3 is : a distance of 40 though 60
Sheet 4 is : a distance of 60 though 80
Sheet 5 is : a distance of 80 though 100
Sheet 6 is : a distance of 100 though 120
Sheet 7 is : a distance of 120 though 140
Sheet 8 is : a distance of 140 though 160
Sheet 9 is : a distance of 160 though 180
Sheet 10 is : a distance of 180 though 200
How can this be automated without writing a ton of nested if statements.
This is an example but in reality I have 29 "sheets" with different ranges to separate.
I have about 20 files with check posting dates stretched over several years. Maybe a million checks total. The company uses 13 four week periods each year, not a calendar month/year. I need to look up each posting date and attach the correct period to it.
I could do a VLOOKUP with one row for each day of the year, but that would require 2 x 365 row's for just two years. There must be a more elegant way, maybe using an array or some IF statement.
Attached is a sample file, xlsx, with the perior/year info and sample posting date info. Can someone point me in the right direction so that I end up with the correct period/year in column 'C' for the applicable posting date?
There are a lot of worksheets with a lot of similar data from which I have to determine the threshold. So if possible I would like to create a macro.
I want to know the threshold value when Y=2.
The threshold can be between different Input Values (=Stimulus Intensity (µA)).
For example: the threshold of amp P2-N1 & P3-N3 lies somewhere between 200 and 252µA. The threshold of P1-N1 lies somewhere between 318 and 400µA.
Is it possible to determine the threshold value with a formula?
I am putting together a spreadsheet and I want to loop through a series of columns (G to L let's say) and in those columns I want to look at a range of rows (4 to 17 let's say). And if that range has no values in it, I want to hide that column and then move on to the next column. I am having a bit of trouble figuring out how to determine if the range is blank and then building that into a loop.
View 5 Replies View RelatedI've recorded a macro that selects a bunch of cells so I can work with them. However, it's hard-coded to the bottom cell of H1551, and I need it to work no matter how large the range is.
Code:
''' Concatenate column H with B & F
Application.Goto Reference:="R2C8"
ActiveCell.FormulaR1C1 = "=CONCATENATE(RC[-6],"" "",RC[-2])"
[Code]....
I have a situation where I have a column with 10 numbers in it... say A1 - A10 each contain an equation that will solve to a numerical value. If one of these does not solve and gives me a "#VALUE!" response, how do I tell a function to look for that? I'm specifically attempting to use Match to find it, in this case "=MATCH("0",A1:A10,0)".
View 4 Replies View RelatedIn cell A1 I have a date entered as text as "Apr 2007". (That's the way my tool pulls it. Format can be changed if it helps)
I was able to pull the Quarter and year (Q2 2007) using...
A2 ="Q" & ROUNDUP(MONTH(A1)/3,0)&" "&YEAR(A1)
I need to pull the next three quarters and their year. (Q3 2007, Q4 2007, Q1 2008)
I am tracking attendance of individuals in an Excel spreadsheet. I would like to determine how many consecutive days each individual has attended. The spreadsheet has two pertinent columns which contain the individual's name and the date of attendance. How can I determine the number of consecutive days of attendance?
View 5 Replies View RelatedHow can I determine if the user selected "disable" at the initial macro prompt screen.
Basically, I would like a formula/function that can say whether Macros are switched on or off by the user.
I have a spreadsheet with a variable number of xlButtonControl type form controls. The actual number of buttons depends on the amount of data that the spreadsheet is being asked to summarise. All the button controls use the ".OnAction" property to point execution on click to a common procedure.
Unfortunately that much is what it is and is beyond my control, so I just have to work with that.
What I would like to know is if there is a property or method I can access from within the common OnAction procedure that enable me to identify which button was pressed. If this was a CommandBar environment I would use the ActionControl property. Since it's not, and since I can't change it (not even to use ActiveX controls!), does anyone know an equivalent that I can use in this case?
I want to determine the range in the countif function automatically and relating to a date (i.e. today).
In the attached sheet there are two employees who worked during a certain period, a day worked is 1
Then I would like to count how many days each employee has worked up until today, counting the 1's in the row of that employee until today.