Keep Variable Values AFTER Procedure Ends
Mar 19, 2007
I have a User Form with 2 groups of 3 radio buttons let's say. The user must choose one button from each group, then press "GO" which runs specific code depending on what buttons they pressed.
How do I make the variables public or static so that after both radio buttons were selected, another seperate procedure in the same module (The GO procedure) can know what selections were made so it can run code based on those selections? In this example, there are only 2 groups of three radio buttons, but in reality I have 30 buttons and it keeps growing so I need the most direct/simple way to solve this.
For Example:
UserForm1
Radio Button Group 1:
Button 1
Button 2
Button 3
Same UserForm1
but now here is Radio Button Group 2:
Button 4
Button 5
Button 6
I need to know which buttons the user clicked from Group 1 and Group 2 after they finished both their selections from each group, and then run code depending on what combination of buttons have been selected. I'm good to go with the If/Then code to decide which code to run, I just cant keep the variables from reading as 'Empty' when I try to see what the user selected when pressing GO and running that procedure.
View 9 Replies
ADVERTISEMENT
Mar 28, 2014
I've got an excel sheet that lets people choose between 2 choices. I'm using scroll bars to make it easy for them to choose and visualize their preference with as little mouse clicks as possible. The scroll bar is only one sided though, meaning it starts from a min value to a max value.
I would like a scroll bar with a of 0, with the value increasing positively as the user scrolls to the left, and the value also increasing positively as it scrolls to the right.
View 2 Replies
View Related
Sep 8, 2007
I have 46 drop downs that I need to call from a main sub. I want to create one loop that will call each one to perform its function. Below is a simple example of what I am trying to do, but where I need help is with the 'Call Y' line. I am not sure what character to use to tell excel to look at what is in the value of Y, not 'Y' itself
Sub testitout()
Dim y As String
For X = 1 To 2
Sheets(" Lookup"). Range("E3").Value = X + 4
y = "dropdown" & X & "_change()" 'this will return "dropdown1_change()" for the first loop
Call y 'i want to call dropdown1_change() below
Next
View 9 Replies
View Related
Jan 19, 2008
I've search here for a bit and could not find the answer to what I'm looking for. I have 2 procedures on the same worksheet. I need to get the value of a variable from a second procedure so that my first procedure can work with it. From the first procedure I call the second, where the value of the variable is calculated, but when I return to the first procedure, the value of the variable seems to get lost.
View 6 Replies
View Related
Apr 10, 2013
i know i have done this before but im totally blanking. I want to user the inputvalue in procedures called from controller, but it just shows as empty.
Code:
Sub controler()
Static inputvalue As Long
inputvalue = InputBox("Please set min size of trades.")
'other macro's called here
end sub
View 4 Replies
View Related
Nov 21, 2006
I'm creating a user form that will have 10 checkboxes on it. Depending upon certain conditions being met elsewhere in the workbook, I would like to populate the checkboxes' captions with data from the workbook.
My question is, can I loop the procedure with the variable number included in the checkbox name (well, more to the point, HOW can I loop the procedure...)?
I would like to do something like this:
Dim a As Integer
For a = 1 To 10
With Worksheets("Hi-Tech")
If .Cells(a + 1, 2).Value "" Then
chkHiTech & a.Enabled = True
chkHiTech & a.Caption = .Cells(a+1, 2).Value
lblHiTech & a.Enabled = True
lblHiTech & a.Caption = .Cells(a+1, 2).Value
etc.
View 6 Replies
View Related
Aug 8, 2014
I have a VBA shell script that worked just fine on another computer, but now it won't run.
The code that won't execute is:
[Code] ........
View 12 Replies
View Related
Apr 19, 2014
Basically, I have six worksheets where I have, on two different columns each,
the code, the quantity, the shelf
Where it is stored.
What I have been asked for is: given the shelf, to have got back all the codes and quantity that there are in this shelf.
My Idea is: in a sheet called <<initial>>, create a cell where I write the value of the shelf (this value in a text).
Then, with a VB procedure, start activating first worksheet, start reading the first column.
if the shelf value corresponds to the required shelf, then activate a sheets called "Results" and write there all the value corresponding to code and quantity.
Then, when ended the column, I would move to the second column. Once ended the second column I would activate the second worksheet.
But I am having some problems since the beginning, since I have problems in reading the value of the shelf column.
I am attaching how I have started to wrote the procedure : [Code] .....
Why I can read the value of the cell ?
View 7 Replies
View Related
Mar 24, 2014
I understand the use of Global variables in the sense that they can be used throughout the project. However, I also understand (I think) that unless these variables (like any) are released from memory or the values changed by some other means they will retain their values when accessed inside a another procedure regardless of where the calling procedure is Public or Private. This seems to be a convenient way to access the values of these variables without having to make ByVal or ByRef declarations in the procedure calling process.
Firstly, is my understanding of this correct? (That the variables and associated values) can be accessed from within a calling procedure without formally passing them in?
Second, even if this is true is it considered to be bad practice because the variables will store the last known value which may or may not be correct if you aren't paying attention to how the variable was last set.
View 2 Replies
View Related
May 23, 2012
Im using excel 2010 As it's 60 times quicker I was trying to speed up my code and replace all loops by putting the value into an array, and then transfer the array to the worksheet
It seems to be straightforward for math calculations like in this example:
[URL]
But no luck with the one below. I was trying to test it on a simple loop which replaces two types of string into the 3rd one:
Code:
Dim lastrow, lastrow2, i As Long
With Worksheets("KPI5")
lastrow2 = .Range("N" & Rows.Count).End(xlUp).Row
.Range("T7:T" & lastrow2).Value = .Range("F7:F" & lastrow2).Value
For i = 8 To lastrow2
If .Range("T" & i).Value = "Modification" Then
[code]....
View 4 Replies
View Related
Jun 27, 2014
I need a macro that will create a sheet at the end of the workbook.
Sum data from a variable amount of sheets and display that data on the created sheet.
Here is a step by step:
Starting on sheet 5.
Column D has a variable amount of part numbers in it. These part numbers would be different between the ascending sheets.
Column T, U, V has an inputed number in it that would need added up across all duplicate part numbers in all the sheets.
(Note: The data would also need started on row 4. Everything above row 4 is headers)
Here is a small example:
D E T U V
13019090W Part A1
68705500 Part B1
64202900 Part C-11
59634600 Part D1
26005300W Part E1
I need the macro to start with sheet #5(starting on row 4). Check to see if there is data in column T, U or V. If there is, to create a new sheet at the end. And copy the entire line into that sheet (starting on row 4).
After that, to check every sheet after (excluding the newly created one, starting on row 4) for data in Column T, U and V. And then check for duplicates in Column D on the newly created sheet. If there is a duplicate to add/subtract that number in Column T, U and V to the SUM in column T, U and V in the newly created sheet. If there is no duplicate, to copy the entire line to the new sheet.
So that when finished. On the new sheet, you have the SUM of T, U and V for everything that has data in T, U or V for all of the previous sheets, plus the entire line of the first instance (excluding the first 4 sheets).
View 2 Replies
View Related
Feb 15, 2009
I am having a with a controlled loop. If the loop is on the last pass and an error occurs, it goes into a never ending loop. Once the error portion of code is excuted, the code resumes to the same line. I'm not sure how to solve this problem. I have attached a sample file with all code if needed.
View 2 Replies
View Related
Mar 4, 2014
Here is what I am trying to do:
Copy the correlating Row from (Worksheet DataDump Column AJ) to (Worksheet Calc Column A)
IF
Worksheet DataDump Column B ends in 3
Here is what I got so far..
Code:
Sub copyWorkPackages()
Dim WPThree As Range
For Each WPThree In Range("DataDump!B2:B" & Range("DataDump!B" & Rows.Count).End(xlUp).Row)
If Right(Range("DataDump!B2:B" & WPThree.Row), 1) = 3 Then
End Sub
View 2 Replies
View Related
Apr 28, 2006
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
If Not Intersect(Target, Range("e273:g284")) Is Nothing Then
Set rng = Range("e273:g284")
ElseIf Not Intersect(Target, Range("g273:j284")) Is Nothing Then
Set rng = Range("g273:j284")
ElseIf Not Intersect(Target, Range("j273:l284")) Is Nothing Then
Set rng = Range("j273:l284")
End If
Application.EnableEvents = False
If Not rng Is Nothing Then
If Application. CountIf(rng, Target.Cells(1, 1).Value) > 1 Then
MsgBox "This vehicle is booked out at this time"
Target.ClearContents
Target.Cells(1, 1).Select
End If
End If
Application.EnableEvents = True
End Sub
the code is perfect for what i need it to do but the only problem i have is that the codes roll on from each other... I.E:- E273:G284 - G273:J284 - J273:L284. first ends in G second starts in G, Second ends on J third starts on J. for some reason this doesnt work, the first code gets the prority and works but the second works in all the columns except the first one.. in this case the first code is fine, second actually works from H not G and third works from K not J
View 2 Replies
View Related
May 10, 2006
I want to copy range A to B, but I don't want to copy the whole column of A. I want to copy the data on A where B ends. For instance, If Column is A:50 and B is B:40 then I only want to copy A:40. I've trying the code below, but for some reason it deletes the range. Once the code is finished there is nothing in A or B.
Range("A9:A" & Cells(Rows.Count, 2).End(xlUp).Row).Copy
Range("B9").PasteSpecial (xlValues)
View 7 Replies
View Related
Jan 31, 2014
I want to subtract a time value which starts today and ends the next day. Is there a way to achieve it as i get error when i do that.
View 3 Replies
View Related
Dec 26, 2011
I have a print macro that runs from a command button, when I use it the workbook goes to the sheet printed. Can I somehow make the workbook go back to a sheet of my choice? Here is the macro, The command button is on a sheet called Control Center, can I return to that sheet or stay at that sheet when I print?
Code:
Sub Button16_Click()
Sheets("OBS1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
View 4 Replies
View Related
May 22, 2006
I have an Excel file with text records, 1000s of lines long Trancriptions of Customer sales reps and Customers, or Distributors. All data is in Collum A.
Each Record has 7-10 Entries
______________________
BILLNUM : 060501
ORIG : 12345678909090
REP : 45672222222222
AREA : LK787878000000
SD : 060401
ED : 062025
COMMENT : CUSOMTER CONVERVERSATION WITH REP
C:HELLO
R:HELLO
C:MAY I HELP YOU
R:BALANCE PLEASE
etc......................
View 3 Replies
View Related
May 22, 2006
If the user adds 3 new lines, to the data table, – the Series Value Ranges should increase by 3 lines – AUTOMATICALLY(!) to avoid the user to full-around with the chart. It should take care of the 4 Series Ranges and also of the Range for the X-Axis Category Labels. As far as I recall, the way to accomplish it, is by NAMING the ranges with COUNTA etcc BUT, here – the last row is an empty rowc
View 2 Replies
View Related
Jul 30, 2014
I need to create a report on each friday as well as on every last workday of a month. I have to display both weekly and monthly data on the same graphs and I always arranged the week ends and month ends myself, but this is taking a lot of time.
So I need a chronological list of of week numbers and month names based on the date of Friday of a week or last workday of a month.
Input:
A1 - either month name ("MMM", Jul, Aug, Sep) or week number (1-52)
A2 - year number (2014)
Output:
For example, for 30 in A1 and 2014 in A2 it should look like this:
BD
BE
BF
BG
BH
BI
BJ
BK
BL
BM
1
May
23
24
25
26
Jun
27
28
29
30
And this should strech back all the way back to B1 in which I need to have 31.
Note if a month ends on last workday of a month the week number should come first and month name second.
View 1 Replies
View Related
May 9, 2006
I am currently working on a project which at various times does 2 different things. These things are to be done on a "PROTECTED" (UserInterfaceOnly:=True ) worksheet.
The first is a Range.Replace command.
The other is a Hyperlinks.Add command.
Now when I'm testing ( typically the worksheet is not protected ) everything works like a champ. But as soon as I protect the sheet the following scenario happens.
1. The replace DOES NOT work.
2. The hypelink.add DOES NOT work.
when the sheet is protected it ends up throwing a runtime error ( 1004 ) "Protected Sheet error" the real odd thing about this is that it doesn't throw the error on the command itself. On the hyperlink the error happens about 3 command further along in the flow............
View 5 Replies
View Related
Jun 14, 2007
I have many worksheets which ends with the word " data". Is there a way to delete all the data sheets at one go through VBA code.
View 3 Replies
View Related
May 17, 2007
Using only basic formulas (no VBA then), I need to solve the problem of a VARIABLE SUM of values:
Starting always from the value 1:
- if “control” is “x”: the formula has to write in its “memory” the value 2 and in the next row the new value will be the sum of the two values (1+2), so 3;
- if “control” is “y”: in the next row we repeat 1.
From this point:
- if “x”: we add to the last value of our series another value that will be the last used value and in the next row and in the next row the new value will be the sum of the left value with the right value of the series (in this moment 1+3), so 4;
- if “y”: the formula has to delete from its “memory” the two values that formed the previous sum (in other words the external values of the series) and in the next row the new value will be the sum of the left remained value with the right remained value of the series maintained in “memory”. If remains only a value in the next row we’ll write that single value.
N.B.: if “control” is “z”: the formula must hold in “memory” the sum of values and write that sum in the next row but without considering because all the operation are “suspended”! When “control” will return to “x” or “y” operations of summing or cancelling will start again.
At the end: when everything will restart from the beginning of a new session with the value 1 and “forgetting” entirely what happened above??
There’re 3 cases:
- when all the values are deleted, in the next row will restart a new session with the value 1 “forgetting” entirely what happened above;
- when the result of the sum is >= $A$2, in the next row will restart a new session with the value 1 “forgetting” entirely what happened above;
- when the value of the column “heart” is >= $B$2, in the next row will restart a new session with the value 1 “forgetting” entirely what happened above.
Excuse my english and if you need any clarification… just ask!
No need for this in only a column, you can use all the intermediate columns you may need.
After spending 3 weeks on this I really hope that someone could help me solving this VARIABLE SUM of values.
View 9 Replies
View Related
Jan 9, 2007
Is it possible to have a cell populated by the value of a Variables obtained (or defined) using VBA? A message box confirms that the variable is indeed defined as desired but I would like its value used in a spreadsheet cell.
View 9 Replies
View Related
May 17, 2007
I run a large macro which combines and compares an Excel file with a download out of our SAP system. One of the selection criteria I have to put in is called 'Plant' and it is a single value which I select from a drop down list. (Values are 1010 1020 1030 1040). In the Macro the value is defined as:
Plant = Range("I21").Value
where I21 is the cell in which the Plant is selected. My question: How can I make the macro take two values into account at the same time, so 1010 AND 1020 in one go? I tried changing the list used in the drop down list but that does not work. Or is it impossible as the plant has been restricted to only one value?
View 5 Replies
View Related
Sep 21, 2011
I would like to have two series of data using the same X axis (date, formatted in months). The Y axis is in intervals of 100,000.
The first data series is historical (actual) data (i.e. Jan 2009 to August 2011). The second data series is forecast (Sept 2011 - August 2012). So i want the forecast series to start immediately after the historical series. It is a 'line with markers' chart. The key objective is that the forecast data looks visually distinct from the historial series.
Excel version: Excel 2010
OS: Windows 7
View 5 Replies
View Related
Aug 20, 2009
I need a bit of help with the below macro which I am trying to create. I recorded the below vlookup, which works perfectly. It checks a list on sheet “Map” and returns a value depending on whether the reference is one of the 6 or not. These 6 are likely to change over time so I would prefer to declare them as variables rather than build them directly into the macro
View 4 Replies
View Related
Feb 18, 2010
I'm working on this sheet and I can't figure out how to do it.
I'm trying to determine the variable "selling price" on the basis of given values, buying price, Net profit and Expenses.
View 4 Replies
View Related
May 16, 2007
I have a list of part numbers in a column and a list of suppliers in another column. Parts may have anywhere from 1 to 15 suppliers.
Is there an easy way to show each part number once down one column, with the suppliers going across the one row for each part number?
Example:
PN#Supplier
123ABC
123DEF
123GHI
123JKL
123MNO
123PQR
456ABC
456DEF
456GHI
456JKL
456MNO
456PQR
456STU
Desired Output:
PN#Sup1Sup2Sup3Sup4Sup5Sup6Sup7
123ABCDEFGHIJKLMNOPQR
456ABCDEFGHIJKLMNOPQRSTU
I tried a pivot table,
View 4 Replies
View Related
Nov 20, 2007
I'm just starting to experiment with passing values between workbooks and between modules and so far I've managed to get it working. However, I now can not run the receiving module independently because of the passed value ? Let me explain ...
I use start/end dates within my modules to create date sensitive reports. I have several files (for different departments) and each file has a module called "AbsenceChecker", I have been working on a way to create a Report Master workbook to run and amalgamate the "AbsenceChecker" module from each department.
Sub RunAllLoaders()
Dim AbsenceStart As Date, AbsenceEnd As Date
Dim PassVar1 As Date, PassVar2 As Date
Dim DateStart As Date, DateEnd As Date
On Error Resume Next
'start of data validation script continued in private sub.
GetValidDates FromDate:=PassVar1, _
ToDate:=PassVar2, _
MinDate:=DateSerial(2007, 1, 1), _
MaxDate:=DateSerial(2007, 12, 31)
Excel.Application.EnableEvents = False
Workbooks.Open Filename:="R:RostersRosterALPHA.xls"
Application.Run "RosterALPHA.xls!AbsenceChecker", PassVar1, PassVar2
End Sub...................
View 2 Replies
View Related