Inscribing Cells: Run A Macro On Enter Keypress, That Would Execute Different Code Depending On That "inscription" That Would Be Invisible To User

Feb 20, 2007

Is there any way to "Inscribe" a cell? I would like to run a macro on Enter keypress, that would execute different code depending on that "inscription" that would be invisible to user. I could use some properties of . Validation property like this:

Private Sub EnterPressed
'following code to ensure proper functioning of Enter in any other Worksheet
If ActiveSheet <> mySheet 'MySheet is global Variable then
ActiveCell.Offset(1,0).Select
exit Sub
End If
'now the real code
If ActiveCell.Validation.InputMessage = "1" Then
ActiveCell.Offset(0,1).Select
Else
'something else
End If
End Sub

The problem is, I use Data Validation and Conditional Formatting, so can't use any of these properties.

View 8 Replies


ADVERTISEMENT

Execute Macro Depending On User?

Sep 29, 2011

I need to execute a macro (just a simple "msgbox") but only if a specific user (or users) have opened the file.

View 1 Replies View Related

Creating Macro Dynamically On Keypress And Execute

Apr 1, 2014

creating macro dynamiccally on keypress and execute it

i have 3 excel sheet sheet1, sheet2, MasterSheet

MasterSheet conatins the following

COLUMN A COLUMN B COLUMN C

Colorcode FLAG SKEYS

RGB(121,223,214) A Ctrl+a

RGB(125,228,114) B Ctrl+b

[code]....

I have 3 columns column 1 contains colorcode in RGB format column 2 Contains FLAG and column 3 contains SHORTCUT KEYS

i have a macro in sheet1 & sheet2 for coloring the backgrouf color of the selected rows in sheet1 or sheet2

Code:
Sub Macro_color()
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = RGB(234, 241, 221)
.PatternTintAndShade = 0
End With

what i need is when th user presses say Ctrl+c , RGB(233,129,220) from the MasterSheet needs to be copied in the macro as .Color = RGB(233,129,220) instead of RGB(234, 241, 221) and the selected row in sheet1 shld be colored. how can it be done

View 1 Replies View Related

Code For Specifying Cells So That Copying And Pasting Macro Will Not Execute There

Feb 20, 2013

I've attached a sample workbook in which there are 3 macro-buttons.

The buttons will paste a shape in the active cell. So this means the buttons themselves could be deleted and replaced with a shape.

Since locking and then protecting the cells disables the macros, how can I amend the code to make sure the buttons' cells are protected from the copying and pasting macros? Or, how do I ensure that the macros only work in A1 - E5?

View 4 Replies View Related

Messagebox Prompt Then Allow User To Enter Data Before Continuing Code Execution

Jun 11, 2013

Basically, in the "Thisworkbook" code , i have some code in the Workbook_BeforeClose section. Currently , it autosaves the workbook in a folder i have specified.

However, i need to add some code.I want to check that a certain cell has a value in it before the user closes the workbook, and if the cell is empty, show a messagebox asking him to enter a value.

I know how to get a messagebox to pop up, the only thing is once the user clicks the OK button,
i need the rest of the code execution to pause, allowing him to make the change then if he clicks the "X" (top right of the screen) to close the file or application, the filesave dialog appears and he can then save the document.

how to go about this because at the moment when user clicks ok, the messagebox just disappears and filesave dialog appears and he doesn't have a chance to edit the cell.

View 5 Replies View Related

Excel 2003 :: Allow User To Enter Post Code And Some Details Will Be Returned Using VLookup?

May 8, 2013

I have produced a basic search/lookup facility on an Excel workbook that simply allows the user to enter a post code and some details will be returned using a vlookup. The document is going to be rolled out to a number of operational users so I want to basically 'lock down' everything I can in the document (basically everything except the data entry cell) and make it fool proof- I have locked all cells apart from the data entry cell and have made the file read only.

The only issue I am encountering is when the cursor is in the one 'unlocked' cell (i.e. the one the users will enter the post code into); it appears that you can break the document. For example, when the cursor is in the 'unlocked' cell, I am able to go to Tools > Options and change various settings including cosmetic colour changes but also cell calculation which breaks the lookup functionality. This is probably enabled as the cell is unlocked, but if I lock the cell, when I protect the document, it disables data entry!

if there is another way of providing this one cell for users to input data into for the vlookup to work whilst locking down the rest of the document to ensure that no-one can break it?

View 1 Replies View Related

VBA If Range Value = Something AND Another Cell Has No Entry- Prompt The User To Enter Data- My Code Is Not Working

Apr 20, 2009

I am trying to display a message box for the user if there is "agency" in cell o8 but nothing in p8... I tried the following code but it doesnt work..


If Range("o8").Value = "Agency" And Range("p8").Value = "" Then

MsgBox "Please provide name of agency in cell p8"

Sheet9.Shapes("cross").Visible = True

Else

View 9 Replies View Related

Execute VBA Routine On Enter Key

Nov 6, 2009

How do I have a workbook execute VBA code when I hit 'Enter' anywhere on a specific sheet? I don't need the code to execute when I hit 'Enter' on any of the other sheets in the workbook, just a specific sheet.

View 11 Replies View Related

User Form That Pops Up When I Enter ‘Y’ In Cells

Oct 14, 2009

What I am after is a user form that pops up when I enter ‘Y’ in cells in Column ‘L’ which displays the contents of the cells in that row e.g. if I enter Y in cell L2 a user form would pop up displaying the contents of cells A2 to M2

The A2 to M2 column headers are:-

First Name
Surname
Code
Address line 1
Address line 2
Address line 3
Address line 4
Address line 5
Post code
Telephone
Comments

The user form can be Read only i.e. I do not need to edit the cells (although that would be good) as it will be used as a source document to input into another application, however, a ‘Print’ button to print the form would be beneficial. The only other button required would be a ‘Close Form’ option.

View 4 Replies View Related

Execute VBA Module By Enter Key Press

May 29, 2014

Is it possible to execute the vba program by pressing the enter key in the excel sheet.

For example i want to input the data in cell A1 and want to press the enter key to execute the written vba program.

View 2 Replies View Related

Execute Sub Via Textbox Or Cell With Enter Key

Oct 3, 2006

I was wondering, is it possible to execute my VBA sub from textbox1 using the enter key?

View 3 Replies View Related

Textbox Enter Key To Force Execute Commandbutton

May 26, 2007

In my userform, I have a textbox where I enter a number.

When I hit the return key in the textbox, I want the userform to act like I hit a commandbutton_Click. (The commandbutton_Click takes the contents of the textbox and locates a line with that number in it in a specific worksheet, and then displays the line of info in other textboxes in the userform).

I have not been able to figure this out.

View 9 Replies View Related

Copying Invisible Columns, But Not Invisible Rows

Nov 4, 2008

I'm using the following code, which I figured out quite by accident out of happy coincidence that somebody else on here asked about selecting only visible rows:

View 4 Replies View Related

Code To Move The Cells Right Depending On The Value On One Of The Cell

May 4, 2007

I have attached the sample file where I have noted what I want as a comment. I need to check for the value " Function Name: RF Pick" if this is there then the code should move 2 rows down check whether that row has the value " Each" if its there just move one row down and move the cells as I need in the output.

View 7 Replies View Related

Vba Code To Get Workbook Name And Enter Into Macro

Mar 9, 2009

I need vba code to retrieve the workbook name and place it into macros. the workbook name does not change in the macro if the name of the workbook changes. so i need to assign the name to a variable then use the variable name as the workbook name............

View 9 Replies View Related

VBA Code For Adding 0 Depending On Cells Amount Of Characters

Aug 5, 2014

I'm working with a column that contains dates. The dates are pulled from a system that doesnt always have dates in the format

mm/dd/yyyy => 09/26/2014

but instead sometimes
9/26/2014
or
4/7/2014

i.e., 0's are missing.

I'm looking for a macro that inserts these missing 0's

**So I suppose the criteria should be that if the cell is 9 characters long (including the "/"s), then it adds a 0 as first character**
and
***the cells that are only 8 characters, in that case there would have to be insert 0 again as character 1, and 0 as character 4 (if 0 is already added as first)***

I'll attach a file that contains dates : test.xls‎

View 6 Replies View Related

Clear Data Depending On User Input And Move Cells Forward Without Deleting Data Table

Oct 25, 2012

I have an month input in cells B2 (user can enter values from 1-5)

I then have a data table that has month 1,2,3,4,5 running across range G9:K9. the data is held in range G10:K19.

So if user types in 4 in B2, what should happen is that months 1,2,3 and 4 the data for these months should be cleared and data in month 5 moves forward into month 1.

So basically, anything left of the month entered is B2 should be cleared and replaced with anything right of the month in B2.

1
2
3
4
5

£11
£133
£29
£193
£100

[Code] ........

View 3 Replies View Related

Enter Array Formulas To Range Macro Code

Apr 23, 2008

I'm trying to enter a series of formulas referencing the first cell of each row.

With Range("A40")
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 1).FormulaR1C1 = "= COUNTIF(Details!R2C2:R65536C2,RC1)"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 2).FormulaArray = "=RC[-1]-SUM((Details!R2C2:R65536C2=RC[-2])*('Details'!R2C11:R65536C11=RC1))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 4).FormulaArray = "=SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C4:R65536C4>TODAY()-7))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 5).FormulaArray = "=RC[-1]-SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C11:R65536C11=RC1)*(Details!R2C4:R65536C4>TODAY()-7))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 7).FormulaArray = "=SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C4:R65536C4>TODAY()-30))"
Range(.Cells(1, 1), .End(xlDown)).Offset(0, 8).FormulaArray = "=RC[-1]-SUM((Details!R2C2:R65536C2=RC1)*(Details!R2C11:R65536C11=RC1)*(Details!R2C4:R65536C4>TODAY()-30))"
End With

While this code works for the first formula, the following 4 are arrays, and for some reason, will only reference the first A40 cell.

View 9 Replies View Related

Excel 2010 :: Add Code To A Macro To Calculate Something Depending On Months

Aug 22, 2012

I am looking for something to calculate values based on the past three months. I already have written a macro to retrieve all of the data and just need this as an add-on.

for example, lets say it is 5/31/2012. I have a row with dates going like

10/31/2010 11/31/2010 .........

I want the formula to calculate SUM(march+april+may row 68)/SUM(march+april+may row 59)

I have an input tab where I can select the month, say 5, and get the periods.

3/31/2012, 4/31/2012, 5/31/2012

if I changed the 5 to an 8 it would get 6/31/2012 7/31/2012 8/31/2012

I don't know if i need VBA for this but I am trying to have something to calculate this depending on the period selected in the input tab.

I am using excel 2010. I am thinking something with an offset function and maybe a loop? but still not sure.

View 2 Replies View Related

VBA Code To Find Date In Column A And Enter Data In Cells On Same Row

Dec 26, 2013

I have a spreadsheet where a date is entered in column A with data in B-F. I am trying to write code to look in column A for a specific date and enter additional data into columns G-L on the same row. It needs to be able to skip the rows that are blank. So I have the dates of 12/1, 12/2 and 12/3 in column A rows 1,2 and 3 and I want to enter data for 12/2 on row 2 skipping the blank cells in row 1 for 12/1. Here is the code I have below.

VB:

Private Sub CBSecure_Click()
Dim my_name As String
Dim r As Variant
Dim l As Long
sFind = DockDoorCal.Value
If Trim(sFind) = "" Then Exit Sub

[Code]....

View 4 Replies View Related

ActiveX Command Button Code To Enter Values From One Range Of Cells Into Another

Jun 15, 2014

well, the clear worked well and now I have another idea for a button for my worksheet;

I want the button to insert values from other cells. so when it is clicked, the values in cells F82-F86 are entered in cells E19 - E23.

View 5 Replies View Related

Enter Text Depending On Another Cell

Apr 8, 2007

I have a spreadsheet which is attached. I want text to be entered into column A only if there is text in column B. The text to be entered is taken from a cell in another workbook. I have removed the lin to up it to this fourm.

View 5 Replies View Related

Program Tab & Enter Keys Depending On Control

Jan 4, 2007

Following are the VBA Object in excel file :

1.TextBox1
2.TextBox2
3. CommandButton1
4. CommandButton2
5. CommandButton3

i want to do following items :
1. when i am in textbox1 and press TAB button from keyboard then cursor go to Textbox2
2. when i am in textbox2 and press TAB (keyboard) then select commandButton1
3. when i am in textbox2 and press enter button (Keyboard) then run the macro of commandButton1 click event.

Actully above VBA object in excel sheet and i am not useing any fram for them .

how to possible above items.

View 9 Replies View Related

To Execute VBA Code @ 9:30:01 Exactly

Dec 27, 2008

Using Excel 2003 with WinXP. I'm trying to run macro code automatically whenever time = 9:30:01 (or whatever time I pick) for a stock market trading program, which is why the exact time matters so much. I've been able to get the time to update fine, but unless I click on the worksheet while the time condition is TRUE then my code doesn't run. The time actually is sent to me from the stock data provider and it shows up in a cell as a constantly updating value.

I've tried using the Workbook_SheetChange function and OnTime method, but without luck.

In both cases, unless I activate the sheet the code doesn't run. By activate, I mean that I have to click on the sheet when the values that trigger the code to run would be true. If I do that it works just fine, but sitting around and clicking on a worksheet defeats the purpose of automation. Since I'm trading stocks this has to be very exact, so I can't trust a macro scheduler to do this.

The code further below is what I'm trying to get to run. The time value is in cell L1. In cell L2 I have the following

View 9 Replies View Related

Macro Won't Execute Code To Put Focus On "print To X Pages Wide By X Pages Tall"

Feb 20, 2009

I'm trying to execute a macro and it won't put the focus (radio button) to select x pages wide by x pages tall in the Page Setup/Page/Scaling Area. I looked at the macro and can't find a setting in the code but yet the focus won't change. What can I do about this? In other words the radio button stays selected as "adjust to "" % of normal size. Here's the code...

View 2 Replies View Related

VBA: Can I Execute Code When I'm WITHIN A Cell (F2)

Jan 4, 2008

Assume a cell -- say A1 -- has a long formula in it. If I select A1, press F2 to "Enter" the cell, then I have a blinking 'l' indicating the cursor/pointer position WITHIN the cell.

Is there any way to control the position of the blinking 'l' (or whatever it is called)? For instance, in a long formula, I would like to write a macro which could transport the blinking 'l' to midway into the formula string.

Alternatively, can I make a partial selection WITHIN a cell and run a macro on it. For instance, if cell B1 has a heading "Dec 2007" and I highlight just the "Dec" portion of the string, I would like to execute a macro to color it red. I have a simple macro that can do it to the entire cell, but not to only part of the cell contents. Is there any way for VBA to be active when I am WITHIN a cell.

Sub Font_Red()
'will add red color to ActiveCell font
Selection.Font.ColorIndex = 3
End Sub

View 9 Replies View Related

Use String To Execute Vba Code??

Mar 30, 2007

how could I use string to execute VBA. For example

x=10
mystring1="for i =1" & " to " & CStr(x)
mystring2="msgbox i"
mystring3 ="next i"

execute mystring1 & mystring2 & mystring1

Like this, I want to combine a VBA CODE string.
And use this string to execute VBA

View 5 Replies View Related

Make Cells Invisible Until They Are Populated?

Jun 5, 2014

I'm trying to create an accounting document, but stuck in couple fields

1) Make balance appear in column E5 only if column C5 OR D5 is polulated, so goes for the rest of the cell in that colu

2) I like to have 2 digits after the decimal but (same as above) i want it to appear ONLY if there are any decimals to that number, all those 0 become confusing.

3) I need to make it so the last calculated cell on sheet Jan of column E gets transfered auto to sheet Feb D3 of F3 so the calculations could proceed to the next month

View 11 Replies View Related

Function Ignore Invisible Cells

Jun 26, 2006

Does this function ignore invisible cells (autofilter) ?

If not, what could be an alternative?

View 14 Replies View Related

Trying To Stop Invisible Cells From Printing

Aug 16, 2006

I have a sheet set up with invisible values in certain cells. To make them invisible, I have coloured the font the same as the backround. The colour used is a light shade of yellow, colour index 36 I think.

Unfortunately, even though the values in these cells are invisble on the screen, they are visible when the sheet is printed. Is there any way to stop these cells from being printed? Note that they are scattered all around the place.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved