USERNAME
USERNAME
(OP)
Hi everyone,
I have just recently started and also I am learning on my own, the VBA code for Macros in Excel.
I just thought, I'll get my problem solved if and only if I share it with scholars over here.
I have a code within a sheet which generates Username when activecell is target. Everything is fine. But, when I run the macro UPDATE to update and refresh the workbook, one entire column is filled with USERNAME!!!
I tried so many things, but i am not able to debug it effectively.
private sub worksheet_change(byval target as range)
...
...
if target.cells.column = 11 then
.offset(0,13).value = application.username
This is within a sheet. The refresh/update code is on the main worksheet.
Please help me!
I have just recently started and also I am learning on my own, the VBA code for Macros in Excel.
I just thought, I'll get my problem solved if and only if I share it with scholars over here.
I have a code within a sheet which generates Username when activecell is target. Everything is fine. But, when I run the macro UPDATE to update and refresh the workbook, one entire column is filled with USERNAME!!!
I tried so many things, but i am not able to debug it effectively. private sub worksheet_change(byval target as range)
...
...
if target.cells.column = 11 then
.offset(0,13).value = application.username
This is within a sheet. The refresh/update code is on the main worksheet.
Please help me!





RE: USERNAME
This code works to accomplish what I think you are trying to accomplish. Note addition of "ActiveCell":
CODE -->
Private Sub worksheet_change(ByVal target As Range) If target.Cells.Column = 11 Then ActiveCell.Offset(0, 13).Value = Application.UserName End SubThis code duplicates the erroneous results you are getting. Note addition of "EntireColumn":
CODE -->
Private Sub worksheet_change(ByVal target As Range) If target.Cells.Column = 11 Then ActiveCell.Offset(0, 13).EntireColumn.Value = Application.UserName End SubRE: USERNAME
RE: USERNAME
Range is ("X2:X2000") ---> column X will have the USER's name.
And this happens when something in column K is changed. (.offset(0,13) ------> offset from column K, is column X )
// What are you referring to by "The refresh/update code is on the main worksheet?" Given the worksheet_change event, nothing is needed anywhere else to execute this code. Anytime any cell in the target range (column 11) is changed, the code will run. //
You are right. Thus my problem is, when nothing is being changed during the refresh of the workbook in THIS sheet, Column X is getting triggered and entire COLUMN is filled by USER'S NAME. WHICH IS WRONG!
Please help! Hope this info was fine to help...
RE: USERNAME
i need to set up a flag so that while the workbook is refreshing, no change should be triggered in THIS SHEET.
RE: USERNAME
IS IT POSSIBLE...?????????//
RE: USERNAME
at the start of the other macro and
EnableEvents = True
at the end.
Doug Jenkins
Interactive Design Services
http://newtonexcelbach.wordpress.com/
RE: USERNAME
RE: USERNAME
RE: USERNAME
If the above doesn't solve it, I'd start looking for event procedures that I might have put someplace by accident that could be triggering changes to the target column and triggering that event.
Can you just upload the workbook? This would probably be resolved a lot faster if you did.
RE: USERNAME