Run Macros When Texbox Gets Data
Sep 18, 2012i have a user form & I would like to run macros when a texbox gets data. If there a "P" I want it to do nothing but if theres an "F" I would like the user Form to unload
View 3 Repliesi have a user form & I would like to run macros when a texbox gets data. If there a "P" I want it to do nothing but if theres an "F" I would like the user Form to unload
View 3 RepliesIs it possible to enable/disable a texbox in excel which has been assigned a macro. To make it clear I'm not talking about a textbox within a userform. I understand I should really be using command buttons but I prefer the look of textboxes.
I have the following code to change the colour of the textbox (name: txtCreateInvoice) but the final line to disable the textbox doesn't work.
Code:
Sheets(1).Shapes.Range(Array("txtCreateInvoice")).Select
With Selection.ShapeRange.Fill.ForeColour
.ObjectThemeColor = msoThemeColorText1
.Brightness = 0.5
End With
Selection.Enabled = False
I have a userform with a variety of checkboxes, textboxes etc which populate their data to cells on the worksheet.I know how to do that and it works fine, but now I need to populate values from multiple items to 1 cell.
For example, if the user selects 3 checkboxes then their respective values are copied across as 3 values in 1 cell rather than one writing over the others.
Is it possible to validate a texbox at entry time to ensure the value entered is a muliple of 6.50.
i.e. ONLY 6.50 or 13 or 18.5 etc is entered. I have used the MOD command at spreadsheet level to accomplish this but have no idea if it's possible at userform / VBA level.
I want to send the value of selected item in texbox , the value format is change by combobox value ..and I want the value is fill on the next column of sheet ( see attached file please)
View 2 Replies View RelatedI have an Excel 2003 program that contains macros. One of the macros hides certain command bars and disables the worksheet menu bar. On close the opposite is true. The problem is, if a user uses the disable macros when opening then the worksheet menu bar and other command bars are still available. I would like to hide all of the data sheets and display another sheet that would normally be hidden displaying a message that the macros have to be enabled for the program to work correctly if disable macros is chosen. When the enable macros are used I would like the Error page to be hidden.
View 6 Replies View RelatedI have a spreadsheet where I'm copying data from one tab to another and also copying values down in certain columns. I have a "chunk" of data already on the tab I'm working on and want to copy an additional "chunk" below it. I want to fill a whole column with the same data but only in my second "chunk". So in this instance...it's an account number and all of the rows in the first chunk have account number 42243 and in the second chunk, I want it to be 78300. The account numbers will always be the same but the number of rows will not be. So for the first chunk, I was able to use the following code...
Code:
'Copies account number 42243 into column C for all lines
MyCount = Application.CountA(Range("a:A"))
Range("C2", "C" & MyCount).Value = 42243
Range("C1").Select
And right now, I have the following in for the second chunk. But obviously what this is doing is putting 78300 in the account field for the entire column, not just the second part.
Code:
'Copies account number 78300 into column C for all lines
MyCount = Application.CountA(Range("A:A"))
Range("C2", "C" & MyCount).Value = 78300
Range("C1").Select
I am importing data from access into a worksheet, and I see the data on my screen in the cells. On Worksheet_Activate, I then want to import the data and then call 2 macros which look at the cells I have imported, and if they are not empty, then manipulate or use the data in another cell. These subs all work as they should, as I can test them by hitting F8 or by running the import sub, then the subs which manipulate that data seperately. When I run them all on activate, the vba works as if the cells are empty, not doing the data manipulation, thought I see they are not empty with my own eyes. Is there some kind of update call I must make? I have tried to add Application.Calculation = xlCalculationAutomatic
View 3 Replies View RelatedI'm working with a data logging system to collect data on a circuit. The logging software allows you to export the data collected to Excel in real time using DDE, and having talked to the logger company I managed to obtain a macro to get the data into excel (I'll put it at the end of the post). This works fine, and I can now press a button and Excel updates itself with the new data every second. What I want to do is quite complicated and I have no idea where to start:
1. The data obtained via the macro only displays in static cells, that is when the new data comes in it overwrites the old one. I want Excel to take a copy of each new bit of data as it comes in, and copy and paste it into a column on the same sheet so that it can be stored. I then want it to move down a row and take the next reading and so on, so that each time a new reading comes in, Excel takes the value and puts it in the next row down in a set column
2. Having a time elapsed measure would also be very useful, so that it records the time after starting the other macro in a column next to the ones collecting the data as described in 1. In this case, each new row would be 1 second further on. The actual time is not massively important, just the 'relative' time since the data collection started.
3. Once the data is copied into the columns to be stored (1.) I then want to calculate two sets of moving averages and place those in columns next to the data. My current plan is one average of 30 samples and another of 5.
4. Once I have the moving averages I can then get Excel to plot some graphs to show the progression of the two values
5. Since my project is revolving around detecting a short circuit in a coil of wire, it is looking for drops in resistance. I want Excel to be able to monitor the two calculated moving averages and if the difference between them exceeds a set threshold for more than 5 samples then some alarm is triggered (for now just a cell changing colour to red or a pop-up box or something).
Unsure how to start this off, any help would be great.
I have a spreadsheet with raw data in it, and am looking for a way to sort the raw data into separate sheets within excel using a Macro / VBA.
Here are the different columns of data I would like to copy into a different sheet.
Man Ord No.
Product No.
Operation Description
There is a Work Centre column I would like to use this column as a way to select the different rows of data.
So if there are five different rows of data for ACT#01 in the Work Centre column I would like it to copy the rows of data, delete all the columns that are not needed that’s all of them except for the above three, then add three new columns below.
Add a column called “Run Time
Add a column called “Resrce Name”
Add a column called “Available”
Work Centre will become the name of the sheet in Excel
The titles of the columns will have to be added in also, via the macro.
See the example excel file that I have started to make by hand, this is just one part of the process that am looking are automating there are other parts as well but just getting started for now.
I have 2 different Clear all data Macros
I will post the 2 different Macros now, then explain a slight modification needed if Possible;
Sub clear()
Dim lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
If lastrow < 3 Then
MsgBox "Nothing to clear!"
Exit Sub
End If
Range("A3:A" & Rows.Count).EntireRow.ClearContents
End Sub
Clear Macro 2
Sub clearalldata()
Dim lastrow As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
If lastrow < 5 Then
MsgBox "Nothing to clear!"
Exit Sub
End If
Range("A5:A" & Rows.Count).EntireRow.ClearContents
End Sub
Basically can the following be added as a fail safe.
I assign a button to each macro (which are on different sheets in workbook).
If I click on say the assigned macro button called "Clear All" for 1 of the macros, can a pop up box appear?
And say, "are you sure you want to proceed" or it could say "Clear All" and have a "yes" and "No" check box?
Quite simply, I've accidentally clicked on these a few times
If this was included in the macro, then I wouldn't loose all my data accidentally
I have a worksheet which has data in column A but I want to repeat it until their a change in data.
I.E say cell A1 has LTP BY001 and the other cells in column A are blank until lets say A30 when LTP BY002 appears. Am I able to run a macro or something that copies the data down until the data changes and then carries on with new data until again it changes and the end of the worksheet
In the attached file (I'm sorry it is zipped, it was just too big), I gave you a snippet of my database. The actual one has 9000+ records. Over in Y4, you'll see the Sum of all the amounts (column X). Run the first macro, that is, Copy Dups, and you'll see it splits the item up by the numbers in column N. This works perfectly (or so it appears.) Then, run the Summary macro (the only other macro in there) and you will see that it pulls the Sums of each spreadsheet and places them on one nice overview page. The summary page. The only problem is, the total of the subtotals on the summary page do not match the total on the main (unadultered) page. I hope i am explaining this right. Somewhere in the macros, I am losing data from my spreadsheets so that the summary page is not equal to the un-macro'd data.
/scratches head
I have a user that keeps a maintenance log in an Excel worksheet and sends an updated copy once a week to a board member. Two weeks ago, the board member started complaining that he was prompted to enable/disable macros on opening and became worried when my user stated that no macros were used in the book. He is now concerned that we have sent him a virus.
I know the file is clean because I've scanned it, and when I look at the file in VB, there are no modules or classes present just the Sheets 1-3 and the ThisWorkbook file. None of these objects have any code in them. My user does have some macros in PERSONAL.XLS but they are not used in the workbook in question.
No one else gets the prompt for enabling/disabling macros. Even if I set my security to prompt for any macros, I get no message. I'm convinced that there must be some setting in his Excel that is causing this individual to get this message. Is there anything else other than a macro that would cause this?
I want to use data validation so that if macros are not enabled, data validation in a particular cell will not allow any entry. Maybe a helper cell that is TRUE if macros have been enabled? How is this done?
View 2 Replies View RelatedAs you can see, I have 2 worksheets. I want that all entries in columns B,D,E and F automaticly fill in in multiple tables in sheet2. Also, if possible that macro creates tables (for example: if I have 100 rows, I want to extract 100 separetly values from column B,D,E and F and to enable automatic creation for new table - for 101 entry )
here is the dropbox link of the file:
HTML Code:Â
[URL]
So, I want when I click on the button I want to automaticly import all mentioned values into sheet 2 (I have marked with RED where to put values from which column). In this example, I expect, when I clik on Print all tables button, to print 7 tables in sheet2. In sheet2 I have 2 tables as you can see.
I have a large excel file with the following columns:
unique ID | Date | Time | D or N | Open | High | Low | Close | Volume
I would like to figure out how to create a table showing:
Date | Highest High of the Day | Time the High occurred | Lowest Low of Day | Time Low Occurred
I think this can be done in a macro where I sort first by the Date column then By the High column but I can't figure out how to get the rest.
I am relatively new to macros and trying to understand how to modify a certain macro that I recorded. Here is what I'm trying to do...every month I have a file with a bunch of data. I need to take that file, filter it, and pull certain data from it into separate tabs within the same workbook. The number of rows of data will change from month to month however I'd like to have a macro that will capture however many lines of data. I have several rows/columns of info I need to copy between tabs but I recorded a macro with just one filter and one row of data for now just to try and understand what I need to do. I have copied it below.
Sub Intersegment()
'
' Intersegment Macro
'
'
ActiveSheet.Range("$A$1:$AF$727").AutoFilter Field:=14, Criteria1:= _
"Intersegment"
ActiveWindow.ScrollColumn = 2
[Code] ........
1- how can i open an xls file from a macros to get some data from it?
2- how can i set a wait function, till i press a special button before macros will be able to continue.
e.g.:
[macros.xla]
transpose raw data to column macros ...
View 9 Replies View Relatedi could do with:
move data up a row if row above is empty
move data left if column before data is empty
tia
add your top 10 if you like
I have a financial model that returns ratios for various years. I would like to highlight in the summary part of the model those years where the ratio is over a set threshold.
For example:
A
B
C
D
...
1
2013
2014
2015
2016
...
2
31%
29%
41%
28%
...
3
Max:
30%
4
2 years over Max: 2013, 2015
In the above example, the threshold (Max) is 30% (cell B3), so the value in A4 would be "2 years over Max: 2013, 2015"
I have been able to do it manually by putting together a COUNTIF function along with various IF statements as follows:
=COUNTIF(A2:D2,">="&B3)&" years over Max: "&IF(A$2>$B$3,A$1&", ,"")&IF(B$2>$B$3,B$1&", ","")&IF(C$2>$B$3,C$1&", ","")&IF(D$2>$B$3,D$1&", ","")...
I even managed to get rid of the final "," by adding a second "," at the end and replacing the expression ", ," using the SUBSTITUTE function (yes, I am a bit **** when it comes to details).
My problem is that I currently have 16 years of projections and, although the above formula works, it requires manual changes every time I add / remove years.
I know that I can do it easily in VBA but the Excel file is to be shared with others via email and I know that their systems are setup to deactivate macros by default (and I don't want to rely on the user having to manually activate macros).
I have been trying to think of a way to get a hierarchy chart automatically with given data through macros
In the attached excel sheet
Org. Charts (hierarchy) question.xlsm
Would it be possible to get the chart to do by itself if say I were to add items or remove items? Is there any way to do it for data automatically?
I extract the data from primavera as attached and I want to make the chart in excel automatically.
I would like to give credit and thanks to StephenR for producing the current Macros in use on this spreadsheet.
This was to sort out Raw Data that I get from a database, and with lots of help sort it and format so for a history of this you can look there.
Now I need to enter in some formulas, data from another spreadsheet and cell formatting…
Unsure if all this is possible but am hoping some of it is…
First Thing
The column Run Time has the data in them already this is the time in minutes am looking for a way to put a formula in, that will make them into hours so the formula will read like this “=180/60” this will give the number 3 as the whole number.
Second Thing
Using the whole number that the formula made in the Run Time column, am looking to fill cells with colour, too see what I mean here its best to take a look at my mock up spreadsheet.
Third Thing
Two rows below all the data that gets sorted out I would like to put in two totals, one for Run Time and another for Available Hrs “=SUM (Range)”
Forth Thing
I have data in another spreadsheet that is the Resrce Name, and Available hrs am looking to take that data from this spreadsheet that will be closed opened if needed, this data will assign workers to Work Centres.
I would like this to be a separate macro to run though all the sheets if possible.
I have 2 workbookts: 1) Product; and 2) Buyers.
1) In the Products worksheet, every column has data about the books' description like:
A | B | C | D | E
Serial | Desc. | Author | Pubd. | year
Column A contains serial no. of the books, ordered from 1,2,3,4,5,6,7 to .....so on...
Columns B,C,D and E, have other details of the books.
2) In the Buyers worksheet, there are two columns;
A | B
Serial | Buyer Info
These are the details people who bought the particular book order by the serial no. of the book purchased.
Required
I need to make a new column in the first worksheet i.e. Product, say F, which I want to read all the buyers' info of that purchase the book with that serial no. and concatenate them together in the same cell separated by a comma.
if there was a way to disable mcros but I think now I should have pursued the option of saving data to new workbook without transfering the existing formulas or macros. I really think I should attach the sheet I have thus far so I can convey what I am trying to accomplish. Anyone interested, please let me know and I will forward the sheet. I am unsure how to do this any other way. I found some code that would claim to do this but I have so many things going on already in this sheet I can't figure out how to incorporate the new code to work properly. Here is the original thread for reference [url]
View 9 Replies View RelatedA spreadsheet that can be used to enter the hours worked by staff each week and then calculate their Gross pay, Tax and Net Pay. THe basic spreadsheet has been created, however it will require aq macro to copy the Week ending, Hours worked, gross pay, tax and net pay columns to the first empty cell in row 1, clear the entries in the week ending and hours worked columns that have just been created and then hide the give columns to the left. which show the data for the previous week.
I know this sounds confusing but ive supplied the file to help you understand. The problem is that we can get the macro to hide the previous five entries and copy 5 new ones in their place but it only does this once. Just about our whole class is having trouble with this as we're not very advanced in macros.
I'm new to Macros and below is my requirement.I need to split my data into multiple rows based on count and the first row should have the value but the other rows should have a value as zero.
Input
Count Value
1 400
2 101
3 300
4 450
Output
Count Value
1 400
2 101
20
3 300
3 0
3 0
4 450
4 0
4 0
4 0
I'm trying to synthesize a fair amount of averages response time data from about 300 separate worksheets into one master sheet and I'm wondering what the best way is to do it using Excel's macros.
In each subject condition-worksheet there are 24 cell items that need to be pulled and put into the master worksheet; there are 2 conditions, for a total of 48 line items.
In each subject file, the subject number is in cell A1, my first desired average is in M7, then M15, M23, M31, M39, M47, M55, M63, then it repeats back to M9, M17, M25, etc..
How can I create a macro that creates a new line for each subject (starting with row 2) first with their subject number (A1 in all subject files), then M7, M15, M23, M31, M39, etc. moving across the row?
What is the commands or script for deleting a macro automatically using
another workbook macro.