Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code Help
Hi, I have a sheet that contains several columns of data. If a user select
any cell in C7 to C10000 then userform 12 opens. I use the following code for this and this part of the sheet works fine, althoug I dont fully understand it. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("c4:c100")) Is Nothing Then UserForm12.Show End If End Sub The problem lies with this, I have another code that copies rows 4 to 7 then finds the last row used in column 'U', activates offset cell (1, -16), selects the activeCell.entire row and pastes the copied data. Each time I run this code, Userform 12 is activated whenever rows 4 to 7 are selected, or any row for that matter because a cell in column 'C' has been activated. I have tried adding Userform12.hide, ive also made a command button that can cancel the userform and made this public and select and activate it using code but to no avail. I have pasted the code below for what I have tried. In a nutshell, i need to close userform 12 when it has been activated. If Rows("4:6").Select Then UserForm12.CommandButton3.SetFocus UserForm12.CommandButton3_Click End If Selection.Copy Range("u7").Select Range("u7").End(xlDown).Select ActiveCell.Offset(1, -16).Select ActiveCell.EntireRow.Select ActiveSheet.Paste Application.CutCopyMode = False Range("C7:C42").Select Selection.Sort Key1:=Range("C4"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("h2").Select Unload Me End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code Help
Try setting Enable Events to False at the top of the procedure and set that
back to True before End Sub Application.EnableEvents = False '<your code Application.EnableEvents = True End Sub -- If this post helps click Yes --------------- Jacob Skaria "Woodi2" wrote: Hi, I have a sheet that contains several columns of data. If a user select any cell in C7 to C10000 then userform 12 opens. I use the following code for this and this part of the sheet works fine, althoug I dont fully understand it. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("c4:c100")) Is Nothing Then UserForm12.Show End If End Sub The problem lies with this, I have another code that copies rows 4 to 7 then finds the last row used in column 'U', activates offset cell (1, -16), selects the activeCell.entire row and pastes the copied data. Each time I run this code, Userform 12 is activated whenever rows 4 to 7 are selected, or any row for that matter because a cell in column 'C' has been activated. I have tried adding Userform12.hide, ive also made a command button that can cancel the userform and made this public and select and activate it using code but to no avail. I have pasted the code below for what I have tried. In a nutshell, i need to close userform 12 when it has been activated. If Rows("4:6").Select Then UserForm12.CommandButton3.SetFocus UserForm12.CommandButton3_Click End If Selection.Copy Range("u7").Select Range("u7").End(xlDown).Select ActiveCell.Offset(1, -16).Select ActiveCell.EntireRow.Select ActiveSheet.Paste Application.CutCopyMode = False Range("C7:C42").Select Selection.Sort Key1:=Range("C4"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("h2").Select Unload Me End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code Help
Thanks Jacob. I cannot believe I have been tearing my hair out and it was
that simple. Every day is a school day! Thanks Ian "Jacob Skaria" wrote: Try setting Enable Events to False at the top of the procedure and set that back to True before End Sub Application.EnableEvents = False '<your code Application.EnableEvents = True End Sub -- If this post helps click Yes --------------- Jacob Skaria "Woodi2" wrote: Hi, I have a sheet that contains several columns of data. If a user select any cell in C7 to C10000 then userform 12 opens. I use the following code for this and this part of the sheet works fine, althoug I dont fully understand it. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Application.Intersect(Target, Range("c4:c100")) Is Nothing Then UserForm12.Show End If End Sub The problem lies with this, I have another code that copies rows 4 to 7 then finds the last row used in column 'U', activates offset cell (1, -16), selects the activeCell.entire row and pastes the copied data. Each time I run this code, Userform 12 is activated whenever rows 4 to 7 are selected, or any row for that matter because a cell in column 'C' has been activated. I have tried adding Userform12.hide, ive also made a command button that can cancel the userform and made this public and select and activate it using code but to no avail. I have pasted the code below for what I have tried. In a nutshell, i need to close userform 12 when it has been activated. If Rows("4:6").Select Then UserForm12.CommandButton3.SetFocus UserForm12.CommandButton3_Click End If Selection.Copy Range("u7").Select Range("u7").End(xlDown).Select ActiveCell.Offset(1, -16).Select ActiveCell.EntireRow.Select ActiveSheet.Paste Application.CutCopyMode = False Range("C7:C42").Select Selection.Sort Key1:=Range("C4"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal Range("h2").Select Unload Me End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does | Excel Programming | |||
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. | Excel Programming | |||
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... | Excel Programming | |||
Excel code convert to Access code - Concat & eliminate duplicates | Excel Programming |