Running Macro In Case Of Changing The Content In Some Range
Nov 28, 2007
I want macro to run automaticly when I change values of any of the cell in worksheets("Data").range(B2:F1000)
Is there any way to write macro only for that worksheet/range?
View 9 Replies
ADVERTISEMENT
Jul 15, 2006
The following code works well unless the user entered the value in lower case.
How can I have it ignore the case of the "W"? I tried case match= false but I must not be using it correctly.
I found another macro on this site that will change the case to caps (note data comes in via copy / paste). Howerver, I was just wondering if it I can do this all in one step instead of two.
Sub DeleteSpecial()
Dim end_row As Integer
Application. ScreenUpdating = False
Application.Calculation = xlCalculationManual
end_row = ThisWorkbook.Worksheets("sheet1"). Range("D65536").End(xlUp).Row
For i = end_row To 2 Step -1
If ThisWorkbook.Worksheets("sheet1").Cells(i, 4).Value = "W" Then
ThisWorkbook.Worksheets("sheet1").Rows(i).EntireRow.Delete
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Also, while I'm in the area, how can I rewrite the above code to actually look for a value of "S" at the same time it looks for "W" and upon finding either delete the row?
View 9 Replies
View Related
Mar 2, 2007
I receive data from different sources and one column is usually in upper case, but I prefer to use proper (title) case. The problem is that the data frequently contains text strings that should remain in upper case or should combine upper and lower case letters. Examples follow:
Data received:
COROLLA AE90, AE92
COROLLA SX, GTI
Data should look like:
Corolla AE90, AE92
Corolla SX, GTi
Note that 'GTi' is upper case 'GT' and lower case 'i'.
I've set up a spreadsheet 'CaseConverter.xls' as a look-up, with a range ('SpecialCase' - A2:A65536) featuring names, codes and acronyms represented correctly. Is it possible to use a macro to run Excel's global replace to search for upper case strings in one spreadsheet and replace with the correct strings from the other spreadsheet? The macro would have to loop through the entire 'SpecialCase' range and look in the supplied spreadsheet for versions of the data in the special case range without being case-specific. The supplied spreadsheet (see attached for example data) is called 'Application.xls'. Column B is what I'm trying to reach.
View 3 Replies
View Related
Apr 5, 2007
I'm trying to do what I thoughts was the simpliest thing, but for some reason can not manage.
I try to change to value of a checkbox, by a code, without re-running the CheckBox_Click () Macro. I have put a checkbox in a worksheet, and when tickmarking it, a msgbox will pop up (one msgbox for tickmark on), and you can press Yes or No. Pressing No, I will sett the Checkbox.value = False. The problem is, when I use this command, the checkbox_click macro will run all over again. Now, the checkbox is False, and antother msgbox will pop up (another msgbox for tickmark off). The results is then that I first get the msgbox I want, but it is followed by the msgbox for tickmark off, which should only pop up when the checkbox is ticked off manually.
Code is something like follows:
Private Sub CheckBox1_Click()
Dim mySheet As Worksheet
Set mySheet = ActiveSheet
Application. ScreenUpdating = False
View 3 Replies
View Related
May 15, 2007
I'm trying to compare two range values within a macro to see if they match...if they do/don't I capture and write some other data.
One list is lowercase, while the other list is UPPERCASE.
My current macro needs them to be in the same case because I'm using the following to compare:
If VPNID.Value = BuildHRName Then
How can I change the format of one of the lists to UPPERCASE or lowercase so that I am comparing apples to apples?
View 9 Replies
View Related
May 8, 2008
Sub Addy()
Do Until ActiveCell. Offset(0, -4) = ""
Renamer = Proper(ActiveCell)
ActiveCell = Renamer
ActiveCell.Offset(1, 0).Select
Loop
End Sub
fail? Trying to remove all capitals from names/addresses. Error message is "compile error - sub or function not defined"
View 6 Replies
View Related
Nov 27, 2008
I am entering a list of usernames in a spreadsheet and some are in different cases.
When I am trying to enter 'FDante' for example, excel keeps changing it to 'Fdante'
I have tried formatting the cell and was even going to try vbcode to resolve this but I assume there must be a simple option that I have overlooked.
View 15 Replies
View Related
May 15, 2008
I am using the following code behind this sheet. In row 9 and column D if I put a lower case letter i want to convert it to uppercase automatically can you see what I am doing wrong.
Private Sub Worksheet_Change(ByVal Target As Range)
'Debug.Print Target.Text & " " & Target.Value & " " & Target.Value2
Dim vVal
'If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Range("C9:D28")) Is Nothing _
And Intersect(Target, Range("G9:H28")) Is Nothing _
And Intersect(Target, Range("K9:L28")) Is Nothing _
And Intersect(Target, Range("O9:P28")) Is Nothing _
And Intersect(Target, Range("S9:T28")) Is Nothing _
And Intersect(Target, Range("W9:X28")) Is Nothing _......
View 9 Replies
View Related
Nov 15, 2008
Thanks for all the help so far with this issue. I seem to be getting errors after running a macro a second time. The name of the cell range is changing. I have attached the spreadsheet and I will try to be specific as possible.
Goal 1: I need to input monthly data into the Sales tab and then save it as a CSV file.
Goal 2: Re-open original xls file that has data then Run macro to create reports.
Goal 3: Save Original xls file as a clean sheet to use again next month.
Process:
1 - Insert Data into Sales tab
2 - File/Save As a CSV (Now the CSV file is open)
3 - Close CSV file and re-open the original xls file
4 - Run Macro to create reports
5 - Print Reports
6 - Manually delete current data on all tabs so I have a clean sheet for next month
7 - Save and Close
Problem:
When I open the xls file (next month) to input new data and run the reports I get a Run Time Error '1004" The Pivot Table field Name is Not Valid
I found that the Named Range of cells changed from the original:
View 8 Replies
View Related
Mar 26, 2014
Currently have a sheet with column A/B. Column A has any of the following letters to represent Wins, Losses, Ties, Overtime Loss, Shootout Loss - W, L, T, OTL, SOL. Column B has team point totals after each result. So after the win in row one, the team has 2 points. After the losses in rows 2 and 3, the team still has 2 points. After win in row 4 the team has 4 points. After win in row 5 the team has 6 points. After tie in row 6 team has 7 points.
W
2
L
2
L
2
W
4
W
6
T
7
What is the best formula or is there a formula to easily calculate running total based on content from column A this for over 1700 rows?
View 9 Replies
View Related
Sep 25, 2009
I have the following Case statement that changes all the cells to the correct color, but does not change the Font color as specified in the Case. All the text is White (fcolor = 2) instead of just the 3 types of cells specified.
View 2 Replies
View Related
Oct 14, 2008
I have created two buttons in a worksheet to navigate to two other worksheets. I would like a cell to display 'YES' automatically if one of the two buttons is clicked and or to display 'NO'. I also would like to change the colors of these cells change automatically depending on which button is pressed.
View 2 Replies
View Related
Jan 8, 2007
I am quite a novice with excel and I am trying to get a cell to show blank when I select a drop down list value in another cell.
Cell D2 contains a validated list containing two items (Air, Vacuum).
If I select Vacuum I wish to change another cells (D4) contents to blank, D4 is also a validated list containing three items (Yes, No, BLANK) the blank is actually a blank space and not the text blank.
I can get the cell to operate correctly but if I select Air in Cell D2 and then Yes in cell D4, but then change my mind and reset to Vacuum in cell D2 i need the cell D4 to clear its contents automatically.
View 9 Replies
View Related
Jun 11, 2013
I have a problem (I have intermediate knowledge of Excel): lets say that I have two model years for Cadillac: 2013 and 2014, and have 3 car models for year 2013 (ATS, XTS, and CRX) and two car models for year 2014 (ELR and CTS Sedan). I want to create a dropdown menu under "Model Year" that will show me 2013 and 2014. When I click on either one, a dropdown list for all car models for that year can appear in the next column under "Models". Then, for each car model, there are different characteristics that are in other columns, such as horsepower, mileage, etc...I want all of the content to stay on one line (row), but change when I click on a different model.
View 2 Replies
View Related
Mar 6, 2014
I have a workbook that has a saved range. I created it with the Name Manager. See below:
[Code]....
When it looks like that the VBA works great and creates my pivots. But after I run my first macro to mess format my source data the range ends up looking like below:
[Code] .......
It is for some reason changing the "A" to "Y".
How I can get it to stay with the original data?
View 2 Replies
View Related
Oct 25, 2006
I’m wondering if it possible to have a variable in a Formula. I was looking around, but non of the other examples I found was working. The code I was trying is:
Sub All()
Dim lngDataRows As Long
Dim lngDataRowsSum As Long
' add sum
lngDataRowsSum = Range("A5").End(xlDown).Row
Range("A" & lngDataRowsSum).Offset(1, 0).FormulaR1C1 = "Sum"
Range("M" & lngDataRowsSum).Offset(1, 0).FormulaR1C1 = "=sum(M6:M & lngdatarowssum)"
End Sub
Another code I tried was from this thread
Sub All()
Dim lngRowsBottom As Long
Dim lngRowsTop As Long
' add sum
lngDataRowsSum = Range("A5").End(xlDown).Row
Range("C10").formula = "=sum(R["&lngrowstop&"]C:R["&lngrowsbottom&"]C)"
End Sub
The error message is: “Compile error: Expected: enf of statement” and the part “[C:R[“ is highlighted. Tried various ways to solve it but nothing was working.
Does anyone of you know how to get it up and running?
View 3 Replies
View Related
Apr 10, 2013
So I found a macro that does something similar to what I need.
I tried changing the data range and input column but it doesn't work.
What the macro does is I type whatever name into the msg box and it will copy and paste all the rows that contains the name to a different sheet.
Here is the macro:
VB:
Sub test()Dim vl As String, res, sh, myrange As Range
Application.ScreenUpdating = False: vl = Application.InputBox("Enter value for Column B", Type:=2): If vl = "" Then Exit Sub
[Code]....
View 5 Replies
View Related
Jul 6, 2006
If I have a formula that uses cells that are currently blank - and then run a macro that puts data into those cells - the original formula cell ranges change - even if I put $ within the ranges.
i.e.
Cell A1 has formula = sumproduct(e1:e10>10)
Currently cells E1:E10 are empty
Run the macro
E1:E10 now has data in.
But formula in cell A1 now reads something like =sumproduct(E13:E23>10) or could read =sumproduct(Ref#>10)
View 9 Replies
View Related
Jun 17, 2013
I'm trying to create a macro that will change the color of the cells I've selected to green. My selection will vary depending on what cells I'm trying to color green (not a fixed range). My current code only changes one cell of my selected range:
Sub IN_PCA()
'
' IN_PCA Macro
'
'
ActiveCell.Select
Range("M243").Activate
With Selection.Interior
[Code] .......
I've tried using "ActiveRange" in lieu of "ActiveCell" as well as other commands that would seem to be correct but have failed.
View 3 Replies
View Related
Apr 4, 2007
I currently have a simply bar chart that is based on a running 5 days figure so the X-axis is like 01-Mar 02-Mar 03-Mar ...
Y-Axis is the data that I am trying to present - Total $
The source of this data is simply two columns - Column A is the running date, Column B will be data.
Daily I need to only present 5 days historical data based on the latest date i.e. today and the past four days (the source data is updated daily).
Can a macro be used to auto update the bar charts based on today's date?
View 9 Replies
View Related
Jan 28, 2014
I have a cell in sheet1 (say, B2) in which I can key a date. Once I change that date, cell C10 updates (after I hit F9 to recalculate) with a new number based on the new date.
I have a list of dates on another sheet, from 1/1/2009 to 12/31/2013, all in column B. I want to produce VBA code that will run through each day, 1/1/2009 to 12/31/2009, in sheet1 cell B2 and take the output in C10 and place it next to each day in column B until it reaches the end (12/31/2013). I know this is possible but for some reason am having trouble coming up with the right looping mechanism.
You can imagine if I had to manually key in each day to get the desired output how tedious that would be.
View 3 Replies
View Related
Jun 27, 2007
Whenever I type " Range", such as in:
Dim myRange As Range
Excel immediately auto-corrects the line as such:
Dim myRange As range
This creates a problem because apparently excel believes "range" is the name of a variable. So when I run the macro, it runs the line and declares the following error:
Run-time error '91': Object variable or With block variable not set
The following is my exact code. The very last line line is where the error occurs.
Dim count As Integer
Dim column As Integer
Dim startRange As String
Dim endRange As String
Dim theRange As String
View 9 Replies
View Related
Nov 19, 2008
What I need to do is have a cell that will be say yellow until there is information put into this cell. The information could be in the format of text or numbers. The information would not always be the same so it would need to be yellow when there is no information in the cell and another colour or white when there is information in the cell.
View 6 Replies
View Related
Jul 31, 2009
I'm creating a small spreadsheet for client data in Excel and I want it formatted a certain way, I did consider data validation but it proved to just be annoying.
I've been working on some VBA code to automatically change whatever text is typed into a cell to the correct case (ucase, lcase or proper) and while I can get it working for a single range of cells getting it to work for more is proving difficult.
View 6 Replies
View Related
Nov 4, 2012
How do you:
Code:
Select Case x
Case _______ -1 = -1 Then
'code
ElseIf x = 1 Then
'code
End If
View 4 Replies
View Related
Aug 26, 2009
I have a string of names that run together without spaces or commas between each name.
"Danny TrejoJean Claude van DammeVincent SchiavelliGabrielle FitzpatrickDavid 'Shark' FralickPat Morita" for example.
Is there a way to add a comma and space between a lower case and upper case letter?
View 7 Replies
View Related
Aug 14, 2006
I have a file with about 30-40 macros in it. In a file with nothing in it, whenever I type the word " range" xl automatically changes it to title case. But I noticed recently everywhere the term 'range' occurs in my macros it is lower case.
View 3 Replies
View Related
Sep 15, 2008
I have been trying to get a certain selection of cells to display inputs as capitalized no matter if entered in lower case. I looked through this forum and found some, I did try some of the suggestions, and I am having no luck. I am wondering what I am doing wrong?
View 12 Replies
View Related
Jun 3, 2009
I've got a pretty intense macro already written, a lot of Select Case components. At the end, if nothing matches I'd like to just copy the cell above to the cell below. However, there is a range of about 400 cells in length, so I'd need some sort of wildcard for range.
Rows("2:2").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Dim Cell As Variant
For Each Cell In Range("A1:OL1")
Select Case Cell.Value
Case "Eng1"
Cell.Offset(1, 0).Value = "Engine One"
tons more in the middle here
Case Else
Cell.Offset(1, 0).Value = "N/A"
Rather then returning "N/A", how could I reference the cell above and just copy it instead?
View 9 Replies
View Related
Aug 6, 2014
I'm fairly new to using VBA and have come into what is probably a simple problem to solve. However, I am looking to sort out my code.
VB:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Cells.Count > 1 Then Exit Sub
If IsNumeric(Target) And Target.Address = "$H$3" Then
Select Case Target.Value
[Code] .....
From the above the macro runs only with the Range H3, I would like have this code operate for the Range H3 to H10... I can't quite get it to work with a few formats I have tried.
View 3 Replies
View Related