Subroutine Stops Before Performing All Commands?
Jun 17, 2013
I have two subroutines. One subroutine updates some figures on spreadsheet 1, and then calls a subroutine that updates some figures on spreadsheet 2. Spreadsheet 2 is supposed to save and close, and return to spreadsheet 1, but it only gets as far as opening spreadsheet 2 and updating the figures. These are the two subroutines:
Code:
Sub UpdateLegalAndMeans()
Dim wBook As Workbook
Dim count As Integer ' counter for counting down backlog figures
[Code]....
View 4 Replies
ADVERTISEMENT
Nov 21, 2006
I was given the following formula by Domenic some time ago that I use along with VBA code supplied by Fin Fan Foom to open do a lookup on a closed workbook:
=If(ISNUMBER(MATCH(MIN(If( Date=D2,If(ABS(Time-E2)<"0:30:30"+0,ABS(Time-E2)))),If(Date=D2,ABS(Time-E2)),0)),INDEX(Contact,MATCH(MIN(If(Date=D2,If(ABS(Time-E2)<"0:30:30"+0,ABS(Time-E2)))),If(Date=D2,ABS(Time-E2)),0)),"")
Everything works fine, until I attempt to…
- cut & paste a block of cells, or
- do a SaveAs, or
- change a worksheet name
The formula will no longer function after performing any of these tasks (the cells go blank), and I have to close the workbook without saving to preserve the original workbook functionality. All other tasks, including even importing of different files into the workbook have NO negative effect.
The formula uses an “INDIRECT” named range. Sheet name changes are reflected in the named ranges, but any change of names somehow causes a malfunction (no sheet names are referenced in the VBA).
I thought that the large lookup workbook (40,000 rows) may be a problem, but even after deleting most of the data and retaining only a few rows, the problem still remained.
After the formula cuts out (after performing the above tasks), if I open up the lookup file, then the lookup will work again, but if I close the lookup file, it will stop working.
I doubt the problem is in the VBA code since IT WORKS, and besides, I have other simple VLookups formulas that also uses the same process (and VBA code) and they continue to work just fine when that one formula gives out. The only thing I can think of is that the complexity of that one formula may be an issue.
Anyway, I the original thread is long, so I’m starting a new one here. The original thread is here (Domenic’s formula, pg 7; FFF’s code, pg 8):
Dedicated Cell To Choose Lookup Table
View 9 Replies
View Related
Jul 12, 2013
I'm a fairly new user to using VBA and I'm currently running into a little snag. I'm trying tu create userform which will let me know if a person already exists in my sheet by looking up the last name in "A", then looking up his first name in "B", if such entry exists then display a message saying " Yes". If entry user has not been entered in the sheet then use a combox, to select the reason , then choose a date ( i have a working date picker ). Then entry should be entered in sheet (Name, Surname, Reason, date).
Whats working, I can use all of the above to enter all the info into the sheet, what I need to do is verify if user is alread in there, if not, then add it. The so on and so forth
View 3 Replies
View Related
Feb 26, 2008
i've managed to get a set of cells to show (with comments) what the last weeks data looked like. (so cell value = this week, comment contains last week)
What i now want to do is to use conditional formatting to highlight any major differences between the figures... so:
My comment i'm sure is stored as text in the format:
Previous value was
xxxxx
So the first thing i'd need to do is to to strip out the text at the start, and then perform the calculation.
View 9 Replies
View Related
Aug 5, 2008
I have the following code which previously was showing an error on the Do While line. It was suggested that I change the line too Range("B2").Text. However, the loop is not deleting the rows based on "#N/A". Can anyone offer any suggestions?
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Header:=xlGuess .....
View 9 Replies
View Related
Mar 13, 2009
I have a very large grid of data, about 400Rx200C, which contains a lot of blank fields. All of this data is currently in values from 0-100 representing percentages, but not formatted as such. I need to make all of these values into Excel Percentages so naturally used Paste Special and Divide from a field with the value 100 in it and then simply format the cells as %.
However, this fills in all of the original empty cells with a 0.000% which I do not want, I need them to stay blank. And some of the cells that do have values also have 0.000% so I cannot just delete all of these values with a VBA script. I had been hoping the Skip Blanks option would do this, but it does not unfortunately.
View 3 Replies
View Related
Sep 22, 2009
I am trying to write a Macro that will do the following.
1. Using a new workbook
2. Open a file in a in a directory. Then
3. Run a vlookup using the opened file as the filename in the vlookup
4. Paste the results of the vlookup into the original file next to the file name.
5. Close the file and open the next one in the folder.
The folder contains about 2k files that it needs to loop through. I found a macro on this site created by Ravishankar and attempted to add to it. Not going so well.
View 2 Replies
View Related
Mar 28, 2014
I am creating a range of numbers from 1 to 2000 with increments of 0.5. Then I have to subtract certain range, for example, 100 to 350. So, the result should display, 1 to 95.5 and 350.5 to 2000.
View 4 Replies
View Related
Jan 19, 2012
The data is a copy of CSV file in to a spreadsheet. Below is what the paste looks like:
100100 Books
1234.ab
1345.bf
1456
1567
100100 Books
100200 Magazines
100300 Videos
1234.ab
1345.bf
1456
1567
100300 Videos
All of the numbers between the 100100 Books, 100300 Videos belongs to that category. This repeats hundreds of rows down. I need the column to the left of this range to display which division it under. I parse this in excel so Books, Videos, Magazines will be in their own column. I am not exporting the CSV so have to manipulate it in excel. I need to have the column to the left combine the whole identifier so I can perform a VLOOKUP on it. It should look as follows:
100100.1234.ab
100100.1345.bf
etc.
My approach was to get the column to the left of the range to display the correct division, then have another column combine by using (cell)&"."&(cell).
View 1 Replies
View Related
Nov 20, 2006
Office 2003 with Windows XP
This is my first post so i may not have done everything correctly. I tried doing google searches to see if anyone else has done something similar but its a tricky thing to search for. I have found pages dealing with manipulating time but none seem to be what I want
I have an Excel sheet with data
A1=date
b1=source
C1-h1 all contain data (name, location, etc, etc) but I am not interested in those.
A1 (the date cell) is formatted like: m/d/yyyy" "h:mm:ss AM/PM
[Sample]
a2 = 8/1/2006 12:20:23 AM b2 = phone
a3 = 8/1/2006 12:21:13 AM b3 = email
a4 = 8/1/2006 12:33:03 AM b4 = phone
This is what I am trying to accomplish:
I want to break each hour, whether it contains data or not and get a count of the different types of source
my desired output would be:
time Phone email
12:00AM
to 2 3
12:30AM
My problem occurs because I am unsure how to break the times down into intervals. In my head, I would create a new column and try to break the time up into an interval. So for a2 (8/1/2006 12:20:23 AM), I think I would need to break the date and time up and then determine which interval would be needed based on the time.
I was going to perform the following:
=text(a2, "h" + if("mm:ss">30, 30,00)
Basically, pull the hour from a2 and evaluate the mins/secs.
If the min/sec is bigger than 30, put a 30 in the box. Less than 30, put double zero in the box. So for 8/1/2006 12:20:23 AM, b2 would have 12:00 since it falls in the 12 to 12:30 interval.
Once I have all the intervals, I would also need to preform a count on the source cell but I think I can use a vlookup to get the count for the interval.
View 9 Replies
View Related
Nov 19, 2009
I have an array with dimensions (5000,30). I want to perform a worksheet function "Percentile" on specific columns within the array. So for instance I may want to know the element falling at the 50th percentile in column 5 of the 30 column array. Is there a way to do this without having to place the array onto a worksheet?
View 4 Replies
View Related
Apr 8, 2014
I have used a vlookup code from a past post (Vlookup multiple values in one cell) in VBA and successfully retrieved my information to one cell.
However, I would now like to remove any duplicates in this cell; preferably while running the same code.
--vlookup code
Public Function mVLOOKUP(mlookup_value As Range, mtable_array As Range, mcol_index_num As Long)
Dim r As Range
[Code].....
View 2 Replies
View Related
May 11, 2007
I have a set of data with names in col A, Currency in col B, Amount in Col C. I want to convert all the amounts in NON-USD based on exchange rate I input daily into column D.
How do i search down the row for the next name that is denominated in GBP / YEN etc and keep converting until I dont find any more other currencies in it. I tried to improvise on the finding nth but couldnt get anything out of it. Have attached a spreadsheet.
View 9 Replies
View Related
May 13, 2014
The spreadsheet has over 200K rows and two dozen columns. My job is to:
1. There are two columns, one is called OCR code where we have repeating ID's and other column is called Minutes Count which is basically a number. I have to filter the OCR column for similar OCR codes(values) and then add their time(Minute Count) so that I get total minutes for a specific OCR code. After adding the min I will copy them into a new sheet with the code in one column, total minutes in another and number of repeatitions for that specific OCR code or count number in a separate column. Example:
OCR_Code; Minutes
54xg; 456
45fk; 65
23IS; 18
54xg; 971
45fk; 265
.
.
.
Now I've to filter 54xg so that I can only see it and its corresponding minutes. Then I will add up all min for 54xg. Then I will count the number of instances a 54xg has been repeated in spreadsheet(here its 2 but it can be in hundreds in my case). Last thing is to transfer all this data to a new sheet. And automatically repeat the process for other OCR codes like 45fk, 23IS etc...
View 3 Replies
View Related
Dec 14, 2013
VBA jumps out of my called subroutine which is stored in a Module halfway.
When I call the SortLec() sub, it runs until y1 = Application.Match(MC & "-" & CI, rng, 0), and then it just jumps back to the SUB commandbutton1_click() IF statement. Why is it that VBA skips the rest of the code from my sub?
Option Explicit
Private Sub CommandButton1_Click()
Dim i As Integer
Dim numofrows As Integer
Dim workbook_directory As String
Dim file_name1 As String
[Code] ............
View 2 Replies
View Related
Mar 14, 2008
Im trying to call another subroutine within the same workbook but it doesnt work,
---------------------
Sub Macro1()
Dim mac1 As Variant
Dim mysub As Variant
Select Case Cells(1, 3)
Case mac1
Call mysub
End Select
End Sub
---------------------
View 9 Replies
View Related
Oct 27, 2008
in writing a subroutine that needs to ask the user
1) tax file number
2) Income
3) tax withheld
It then needs to use a function that i already made called 'incometax' that calculates 'taxpayable' and use that to calculate taxreturn (difference between 'taxpayable' and 'taxwithheld').
I then need it to output like this in a message box
Estimate for tax file number: .....
Created on ......
Total income: ......
Tax witheld: .......
Tax payable: ......Tax return: .......
View 9 Replies
View Related
May 23, 2007
Is calling a subroutine within another different than running it from the play button in the VB editor? I am getting different results.
I have the following code that I want to call from another subroutine that creates a series of command buttons.
Sub DynamicButtons()
Dim ButtonCount As Integer
Dim ctl As OLEObject
' Create the Button objects
ButtonCount = 0
For Each ctl In Sheets("Sheet1").OLEObjects .............
View 9 Replies
View Related
May 12, 2012
How I use the Private Subs for Workbook_AddInInstall and Workbook_AddInUninstall with my addins and confirm it is nececessary to use them?
For 2 weeks, I have not been able to get my addins to activate and load into the AddIns tab. I think these missing Subs are why. Ironically, Every example on how to create addins never mention this step or it being necessary. I've even looked in Macros book and it does not mention anything about needing these subs in the Creating AddIns section so they will show up in the AddIns Tab.
How I can get my Addins in the tab and not the Quick Launch menu
View 8 Replies
View Related
Apr 3, 2014
Is it possible to refer to an object which is in another subroutine?
Or should i have to give its definition in each sub i need it?
View 7 Replies
View Related
Feb 26, 2014
I need to allocate an existing subroutine (its code below) to a new button I'd like to add to my sheet. Two questions arise: to use "form control" or "activeX"?, also should I redfine the first line of the code?
[Code] .........
View 4 Replies
View Related
Mar 26, 2009
I want to pass the name of the routine as a parameter.
View 6 Replies
View Related
Feb 20, 2010
My code passes a string created by a function to procedure. It all works great, but i need to add something so that if the string = false then sub doesn't run. What's the best way to do that. Here is some of the
View 6 Replies
View Related
Nov 17, 2013
I met problem in calling into a subroutine. It is error 424. I have dim all variable. However I still get it.
Code:
Sub UpdateAll()
'
' UpdateAll Macro
[Code]....
I got the error when I pressed F8 to step into the getOneRecord() function, which is highlighted in red.
View 2 Replies
View Related
Dec 23, 2007
My code defines a variable: newrow. Then I call a subroutine using the Call command.
The subroutine does not recognize newrow.
It says it has value zero. How can I pass the value of newrow on to the subroutine.
View 9 Replies
View Related
Mar 6, 2008
I have 60 checkboxes on my spreadsheet and basically, when any of the checkboxes are clicked on, the same action should be performed.
The only way I know how to do this is if I were to write the same code 60 times... one for each checkbox_click() method.
View 9 Replies
View Related
May 12, 2006
1. Can a Subroutine be called from within a user-defined Public Function? How?
2. Is there a difference between calling a subroutine with a 'Call Sub_Name' statement, vs. calling the subroutine with an 'Application.Run'(?? or similar) statement?
View 5 Replies
View Related
Jan 30, 2008
I lost my command bar and tool bars (excel 97) all I have is the blue bar on top then the column letters. How do I restore them?
View 9 Replies
View Related
Dec 4, 2009
I would like someone to explain the reason why when the program is run, the maximum value in column S successfully is selected by being colored in pink, but the minimum in column R between those pink max's (indicated by the entire row outlined in red) is not the minimum.
In other words, look at the numbers in column R. Only the 14.08 rows are supposed to be boxed in red. I can't understand why the 30.08 and the 46.08 are boxed in red??? And puzzling to me is why the 46.08 near the top are boxed, yet the 46.08 near the bottom are not boxed.
View 7 Replies
View Related
Aug 1, 2014
I have a short subroutine to delete a row in a second worksheet (SUMMARY EXPENSES) if one is deleted in the main worksheet (AS CODES) as per below:
[Code] .......
In theory the row deletion should only be triggered IF dynamiccounter is smaller than staticcounter, but the fact is anything whatsoever triggers the row deletion. If I type text into a cell a row gets deleted. If I copy a cell, a row gets deleted. It works great at deleting the line, but I suspect it has nothing to do with the counters I set up and the reassigning of the counter value towards the end of the If statement.
View 4 Replies
View Related