Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro Help - Fairly Advanced.
Hello,
This is a bit of a re-post, but it seems to have fallen off the radar a bit. I have a macro that populates the username in a cell, that works fine. But I dont want to have to Run the macro (or use Ctrl+Shift+U, as i have assigned) for this to populate. The username is needed to populate in M, based on the value of column K being V For example: K M ----------- v username v username v username v username K can only be "v" due to Data Validation. But it can be on any row. Basically to put it in formula terms. =IF($K1="v", Run Macro in M1) Is this do-able? Ive seen suggestions with absolute cell references, but this isnt absolute. If anybody can help, or tell me if its even possible, it would be much appreciated. |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro Help - Fairly Advanced.
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "K:K" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If .Value = "v" Then .Offset(0, 2).Value = Environ("Username") End If End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "NPell" wrote in message ... Hello, This is a bit of a re-post, but it seems to have fallen off the radar a bit. I have a macro that populates the username in a cell, that works fine. But I dont want to have to Run the macro (or use Ctrl+Shift+U, as i have assigned) for this to populate. The username is needed to populate in M, based on the value of column K being V For example: K M ----------- v username v username v username v username K can only be "v" due to Data Validation. But it can be on any row. Basically to put it in formula terms. =IF($K1="v", Run Macro in M1) Is this do-able? Ive seen suggestions with absolute cell references, but this isnt absolute. If anybody can help, or tell me if its even possible, it would be much appreciated. |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro Help - Fairly Advanced.
On 19 Jun, 14:28, "Bob Phillips" wrote:
Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "K:K" * * '<== change to suit * * On Error GoTo ws_exit * * Application.EnableEvents = False * * If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then * * * * With Target * * * * * * If .Value = "v" Then * * * * * * * * .Offset(0, 2).Value = Environ("Username") * * * * * * End If * * * * End With * * End If ws_exit: * * Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "NPell" wrote in message ... Hello, This is a bit of a re-post, but it seems to have fallen off the radar a bit. I have a macro that populates the username in a cell, that works fine. But I dont want to have to Run the macro (or use Ctrl+Shift+U, as i have assigned) for this to populate. The username is needed to populate in M, based on the value of column K being V For example: K * * *M ----------- v * * * username v * * * username v * * * username v * * * username K can only be "v" due to Data Validation. But it can be on any row. Basically to put it in formula terms. =IF($K1="v", Run Macro in M1) Is this do-able? Ive seen suggestions with absolute cell references, but this isnt absolute. If anybody can help, or tell me if its even possible, it would be much appreciated.- Hide quoted text - - Show quoted text - This should work, i can tell, but it doesnt. Can i just ask where its drawing the Username information from, or if i need to add more to the code? |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro Help - Fairly Advanced.
On 20 Jun, 11:55, NPell wrote:
On 19 Jun, 14:28, "Bob Phillips" wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "K:K" * * '<== change to suit * * On Error GoTo ws_exit * * Application.EnableEvents = False * * If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then * * * * With Target * * * * * * If .Value = "v" Then * * * * * * * * .Offset(0, 2).Value = Environ("Username") * * * * * * End If * * * * End With * * End If ws_exit: * * Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "NPell" wrote in message .... Hello, This is a bit of a re-post, but it seems to have fallen off the radar a bit. I have a macro that populates the username in a cell, that works fine.. But I dont want to have to Run the macro (or use Ctrl+Shift+U, as i have assigned) for this to populate. The username is needed to populate in M, based on the value of column K being V For example: K * * *M ----------- v * * * username v * * * username v * * * username v * * * username K can only be "v" due to Data Validation. But it can be on any row. Basically to put it in formula terms. =IF($K1="v", Run Macro in M1) Is this do-able? Ive seen suggestions with absolute cell references, but this isnt absolute. If anybody can help, or tell me if its even possible, it would be much appreciated.- Hide quoted text - - Show quoted text - This should work, i can tell, but it doesnt. Can i just ask where its drawing the Username information from, or if i need to add more to the code?- Hide quoted text - - Show quoted text - Oh, sorry, i didnt say thankyou! I do appreciate you helping, Bob. |
#5
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro Help - Fairly Advanced.
No problem.
It gets the username from the system login. In what way does it not work? -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "NPell" wrote in message ... On 20 Jun, 11:55, NPell wrote: On 19 Jun, 14:28, "Bob Phillips" wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "K:K" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If .Value = "v" Then .Offset(0, 2).Value = Environ("Username") End If End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "NPell" wrote in message ... Hello, This is a bit of a re-post, but it seems to have fallen off the radar a bit. I have a macro that populates the username in a cell, that works fine. But I dont want to have to Run the macro (or use Ctrl+Shift+U, as i have assigned) for this to populate. The username is needed to populate in M, based on the value of column K being V For example: K M ----------- v username v username v username v username K can only be "v" due to Data Validation. But it can be on any row. Basically to put it in formula terms. =IF($K1="v", Run Macro in M1) Is this do-able? Ive seen suggestions with absolute cell references, but this isnt absolute. If anybody can help, or tell me if its even possible, it would be much appreciated.- Hide quoted text - - Show quoted text - This should work, i can tell, but it doesnt. Can i just ask where its drawing the Username information from, or if i need to add more to the code?- Hide quoted text - - Show quoted text - Oh, sorry, i didnt say thankyou! I do appreciate you helping, Bob. |
#6
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Macro Help - Fairly Advanced.
On 20 Jun, 18:42, "Bob Phillips" wrote:
No problem. It gets the username from the system login. In what way does it not work? -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "NPell" wrote in message ... On 20 Jun, 11:55, NPell wrote: On 19 Jun, 14:28, "Bob Phillips" wrote: Private Sub Worksheet_Change(ByVal Target As Range) Const WS_RANGE As String = "K:K" '<== change to suit On Error GoTo ws_exit Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If .Value = "v" Then .Offset(0, 2).Value = Environ("Username") End If End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "NPell" wrote in message ... Hello, This is a bit of a re-post, but it seems to have fallen off the radar a bit. I have a macro that populates the username in a cell, that works fine. But I dont want to have to Run the macro (or use Ctrl+Shift+U, as i have assigned) for this to populate. The username is needed to populate in M, based on the value of column K being V For example: K M ----------- v username v username v username v username K can only be "v" due to Data Validation. But it can be on any row. Basically to put it in formula terms. =IF($K1="v", Run Macro in M1) Is this do-able? Ive seen suggestions with absolute cell references, but this isnt absolute. If anybody can help, or tell me if its even possible, it would be much appreciated.- Hide quoted text - - Show quoted text - This should work, i can tell, but it doesnt. Can i just ask where its drawing the Username information from, or if i need to add more to the code?- Hide quoted text - - Show quoted text - Oh, sorry, i didnt say thankyou! I do appreciate you helping, Bob.- Hide quoted text - - Show quoted text - Ah ok. Well, It just doesnt show anything when i do put the "v" in cell in Column K. It just seems as if it doesnt run or doesnt register. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Creating an advanced Macro | Excel Discussion (Misc queries) | |||
Help with fairly advanced list/print macro. | Excel Discussion (Misc queries) | |||
Advanced macro | Excel Discussion (Misc queries) | |||
HELLLP!!!! This should be fairly simple I would think! | Excel Discussion (Misc queries) | |||
Fairly Complex IF Statement | Excel Worksheet Functions |