Macro Button To Clear Certain Cells
Jan 26, 2009My Workbook with a macro to clear ONLY the highlighted Cells.
The Highlighted Cells can be found on the sheet "Line 5"
My Workbook with a macro to clear ONLY the highlighted Cells.
The Highlighted Cells can be found on the sheet "Line 5"
I have attached a test workbook excel 2010 (ignore ref# errors, I've cut the workbook down for uploading purposes) What I would like to do is have a 'Button' on my 'information Sheet' which when clicked would clear certain cells. I have searched the forum but can't find a solution, everyone seems to want to delete rows or columns but I just want to clear certain cells. The workbook will have 11 sheets each named 'caravan 1' through to 'caravan 11' The uploaded test workbook only only has 3 sheets.
On 'caravan 1' (which is slightly different to the other 10) I want to clear the content of cells
B4 & B5
C4, C22 & C41
D4 & D5
E4,E5, E22,E23,E41 &E 42
On all other 'Caravan sheets' I want to clear the contents of cells
D4 & D5
E4, E5, E22, E23, E41 & E42
It would be icing on the cake if it could give a warning such as " are you sure you want to clear these cells" but that isn't really necessary. The worksheets will be password protected, but the cells mentioned above will not be. If it proves too difficult to clear all the cells on all the sheets with one click, then perhaps a simpler solution might be to have a button on each sheet instead
I'm putting together a time sheet that can used to calculate total hours worked by department etc. I plan on protecting the worksheet and only allowing certain cells to be selected and data entered.
Is there a way using VBA to place a button on the first spreadsheet that will clear all cells that are 'unlocked'?
I have created a command button, right clicked the button and selected 'View Code'. In the code window I've entered the following code:
Private Sub CommandButton1_Click()
IB_FB_Hedge_3 Outcome.range(W10:X11).ClearContents
End Sub
As soon as I enter the code a message pops up:
"Compile error:
Expected: list separator or )"
Is my syntax wrong? Is the sheet name, 'IB_FB_Hedge_3 Outcome' not allowed?
When I created this code a few minutes before I was not having the 'Compile error' problem, but the Command Button was not working either. When I clicked the command button it would just show the circles at the corners, suggesting that it is still in editing mode and not properly activated as a command button.
How do You Make a Button to Clear Certain Cells?I don't know how to make a button that clears a1-a5 and b1-b5. How do you do this?
View 5 Replies View RelatedI would like to run a macro that would check if the date in the first cell of row is in the past.
If yes, then it would clear contents of cell in B,C,F,I,L of the same row (PLAN + SHIFTS). Or even better it would set them to 0 (zero).
Then it would hide the entire row. Is this even possible?
Please see the example: Excel.JPG
Macro to clear cells with numbers but no cells with formulas with in this macro:
Dim i As Long
i = Range("E3")
If i > 0 Then
' Copy range
Range(Cells(6, 10 + i), Cells(500, 17)).Copy
Range(Cells(6, 10), Cells(500, 17)).Select
' Paste special
ActiveSheet.PasteSpecial Format:=2, Link:=1, _
DisplayAsIcon:=False, IconFileName:=False
' Clear i columns on the right
Range(Cells(6, 18 - i), Cells(500, 17)).ClearContents
End If
End Sub
The range is where the cells with numbers need to be cleared but not the ones with formulas.
I have data in columns a,b,c and d from row 1 to about 200 right now. Every week another 9 rows are added. I wanted to create a macro that will delete the last 9 entries in each column.
if I had text in column A, I would like to clear all the cells to the right and leave the text in column A.
Also, if I had text in column A and B, I would like to clear the cells to the right.
I am looking to create a macro to copy sheet Day(1) and call it Day(2). I would like Y3 to increase one day with the date, I would like Y4 to increase day and 1 and clear data from G35-G65.
View 4 Replies View RelatedI'm trying to create macro that will clear the contents of the cells in the 4 columns to the left of a cell that = 0 %, as well as the cell that = 0%. For example, if cell F13 = 0 % then the contents of B13:F13 would need to be cleared. The range in which data is being pasted into is B13:F27.
View 4 Replies View Relatedis there a way to do this in VBA? I've also read: - Dave Hawley's recommendation of using: Sheet1.UsedRange.SpecialCells(xlCellTypeConstants).ClearContents
from another thread (which is excellent!)
- SHG's recommendation of using a named range, for example:
Range("Inputs").ClearContents
Given my limited knowledge of VBA, how would I now combine the two to write a VBA sub-routine that clears a named range entitled "Entry" on a sheet entitled "Data"? Would the following be the correct syntax: Worksheets("Data").Range("Entry").SpecialCells(xlCellTypeConstants).ClearContents
I want to create a command button that will clear whatever is written in a text box. I guess for this to work it needs to select all, then clear. The command button and the text box have been created using the control toolbox.
View 2 Replies View RelatedIn ThisWorkbook Userform2 is triggered upon a double click
Private Sub Workbook_SheetBeforeDoubleClick(ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
UserForm2.Show
End Sub
Userform2 has Frame1 (Option Buttons 1-6) and Frame2 (Option Buttons 7-12)
Private Sub OptionButton1_Click()
Call ProjectBuildings
Range("A1").Select
End Sub
Private Sub OptionButton10_Click()
Call BondIndustrial
Range("A1").Select
End Sub
The user can click away and things work great. The macros that are triggered search a number of Workbooks and individual Worksheets looking to select either of two (hence the two Frames) specific items.
If the user clicks any Option Button in Frame 1 (works) then any Option Button in Frame 2 (works) then goes back to the same Option Button in Frame 1 (nothing) I have a problem.
How do I clear the first Option Button in Frame 1 after the user selects another Option Button in Frame 2?
I have a CLEAR FORM command button
What codes can I use so that when I click CLEAR FORM, all the data that I encoded in the textboxes of my current userform will be erased as if I have a fresh new form?
I'm just finishing a project that is a collection of three calculators, each of which returns data based on a series of user-supplied variables. All the mechanics are working [thanks in part to replies to previous posts], but there is one more thing I'd like to add:
Does anyone have a way to clear the contents of another cell [actually several] cells via another cell? As the most complex calculator requires eight variables to be entered, I'd like to provide a quick way [a button?] to "clear" or "reset" the calculator - basically wipe all unlocked cells. I should note that all of the cells in question already have Data Validation of one type or another.
I keep encountering an error while creating multiple sheets within the same workbook. This is a known error by Microsoft as documented here. In order to avoid using multiple workbooks i need to clear excels cache each time I run the macro as i have limited users sheet creation to 30 sheets which should not trigger the error. Does any one know a code to clear excels cache or memory?
I have used cutcopymode = false but that does not do the trick.
I have a button on my userform that I would like to clear all entries in column B in a sheet called "6 Entries" when pressed
Is there a code for this ?
I have seen this before in spreadsheets so I atleast know it is possible.
I have a worksheet that has 6 sheets in it. The final sheet is a formula page that only shows results if sheets 2-5 have data. Sheet 1 holds all the master data. Sheets 2-5 show subsets based on sheet 1. I manually atm filter sheet 1 for certain info and then copy paste into 2-5.
Seeing as I do this weekly. How would I go about adding in a 7th tab or even a macro that will delete all data from row3-end in tabs 2-5, then copy the appropriate data from tab 1 based on a set criteria?
I could write this in a macro just wondering if there is an easy built in way?
Function FindNth(Table As Range, Val1 As Variant,Val1Occrnce As Integer, _
Val2 As Variant,Val2Col As Integer, ResultCol As Integer)
Dim i As Integer
Dim iCount As Integer
Dim rCol As Range
For i = 1 To Table.Rows.Count
If Table.Cells(i, 1) = Val1 And _
Table.Cells(i, Val2Col) = Val2 Then
iCount = iCount + 1
End If
If iCount = Val1Occrnce Then
FindNth = Table.Cells(i, ResultCol)
Exit For
End If
Next i
End Function
To use this function, push Alt+F11 and go to Insert>Module. Paste in the code, push Alt+Q and save. Use the function as shown in graphic example. You can access it under "User Defined" in the Paste Function (Shift+F3).
Type Amount Sex Cost Purchased
Cat 1 Male $ 5.00 22/05/01
Cat 2 Male $ 5.00 15/00/00
Dog 3 Male $ 20.00 25/04/00
Rat 5 Female $ 1.00 15/08/01..................
I am trying to create a command button in Microsoft Excel (Office 2000) that enables me to reset the check box status for a worksheet from checked to unchecked. The worksheet contains approximately 50 check boxes and is meant to be reused. Is this possible? If so, how can I program it to do so?
View 2 Replies View RelatedI'm having a problem with a macro clearing a formula in a cell. I have the same type of cell that doesn't have the problem but I can't find the difference between the 2 cells or difference in vb that's making it happen. I have to intentionally cause this to happen but don't see why it's happening. Do I need to attach workbook and describe what's happening? I have been copying and pasting from different sources as well as paying to have it created/started but it was expensive(for me) and I make nothing off of it, just use it at work. I am not proficient in Excel or vb but I'm desperately trying to learn as I go so as not to fork out a few hundred dollars again.
here's atleast the vb for the macros:
VB:
Sub clearclientinfo() '
'
'
'
Sheet5.Select
[Code].....
I have a spreadsheet containing 100 "requests" which can be made by a user
i would like the option for the user to be able to delete a request should they wish it either by deleting a row or clearing the contents
Currently I have a single column which is full of buttons (one for each row)
when i click the button on row 10 I would like row 10 deleted
when i click the button on row 30 i would like row 30 to be deleted etc
is there a way to do this without writing 100 macros which are specific to each line?
I've got a button with the following code:
Sub uncheck_all()
Dim sh As Shape
Application.ScreenUpdating = False
For Each sh In ActiveSheet.Shapes
[Code]....
Currently, the button just unchecks a bunch of checkmarks. I want to modify the code so it also makes the value in cell C13 change to -9999, C14 to 9999, C16 to -9999 and C17 to 9999.
how to integrate that into the formula?
how to auto fill of same value in different cells in a row?
For Example:
A1 D1 E1 G1 K1
10 10 10 10 10
like that when i hit a macro button the values in the A1 D1 E1 G1 K1 must fill with A2 D2 E2 G2 K2
I have a sheet with various pivot tables and charts, I want to have a row of buttons at the top to jump to the corresponding cell range.
View 1 Replies View Relatedhow i might create a macro to attach to a button so i can delete the contents of all VALUE! cells. Either this or have a script in the background so no cell will return VALUE! (or any other error if possible)
I know if i had all the formulae sorted they might not butit's quite a large spreadsheet. The reason for the VALUE! error is text in cells that the formal points.
Context: I have a spreadsheet that contains a list of employee names and their certifications. I want to be able to assign a button to each employee in column B with a macro that is able to zip files from a folder that contains that employees name.
The following code assigns buttons to each employee in column B. At the moment the code I have is able to assign the macro "Zip" to each button.
[Code] .....
Now, this Zip macro is able to zip the file for the employee "Anthony Tran". However I need it to be able to recognise which employee's button I've clicked and search the same files as above except with that employees name instead of "Anthony Tran".
If it makes things easier, the code for creating buttons for each employee is able to name that button as the employees name that it represents.
This is probably really straight forward but cant see why it happens, the following macro works fine when called by a button created by the form toolbar but doesnt when called by a command button, get the runtime error 1004, "select method of range class failed"
ActiveSheet.Select
Range("B4:B37").Select
Selection.ClearContents
Range("G4:G37").Select
Selection.ClearContents
Range("B1").Select
Selection.ClearContents
Range("D1").Select
Selection.ClearContents
Range("F1").Select
Selection.ClearContents
Range("J1").Select
Selection.ClearContents
Range("M2:M3").Select
Selection.ClearContents
Range("B4").Select
ActiveWorkbook.Save
Application.Quit
1) We need the Input screen to auto clear the fields once the " Save " button has been pressed and data transfered to the appropriate tracking sheet
2) We want to ensure that if any of the Red cells are empty the " Save " button will give an error ( one complication If the "Transfer Type" highlighted in Blue has an entry " either STD/ISD/ESP " then " Call Purpose " needs to be mandatory
3) somehow the information on the "Comment " field is not getting captured
4) If possible we want a warning indicator if two rows in a tracking sheet ( example London ) are the same based on Coloums B to I ( except C )
5) Is there any possibility to give a pop calender in the " scheduled date " section of Input screen (Row 33)