Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 187
Default Can such a macro be created?

I have an Excel workbook with 2 sheets namely EMP REG and EXIT with more than
400 rows. When employees are going exit I will enter EXIT in Column Q of
Sheet EMP REG. My idea is when I enter EXIT in Column Q that entire row must
be cut from EMP REG and pasted in the last blank row of Sheet EXIT. Can this
be achieved with some code? Thanks in advance.

Jaleel

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,934
Default Can such a macro be created?

This macro should do what you want (although I would test it on a copy of
your workbook first, just to be sure)...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastExitRow As Long, Cell As Range
For Each Cell In Target
If Cell.Column = 17 Then ' 17 = Column Q
If UCase(Cell.Value) = "EXIT" Then
With Worksheets("EXIT")
LastExitRow = .Cells(Rows.Count, "A").End(xlUp).Row
Cell.EntireRow.Copy .Cells(LastExitRow - (.Cells( _
LastExitRow, "A").Value < ""), "A")
Cell.EntireRow.Delete
End With
End If
End If
Next
End Sub

--
Rick (MVP - Excel)


"Jaleel" wrote in message
...
I have an Excel workbook with 2 sheets namely EMP REG and EXIT with more
than
400 rows. When employees are going exit I will enter EXIT in Column Q of
Sheet EMP REG. My idea is when I enter EXIT in Column Q that entire row
must
be cut from EMP REG and pasted in the last blank row of Sheet EXIT. Can
this
be achieved with some code? Thanks in advance.

Jaleel


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 187
Default Can such a macro be created?

Rick,

Excellent. It is working exactly as I wished! Hats off to you! So there
are people who can do wonders.

Thank you very much.

"Rick Rothstein" wrote:

This macro should do what you want (although I would test it on a copy of
your workbook first, just to be sure)...

Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastExitRow As Long, Cell As Range
For Each Cell In Target
If Cell.Column = 17 Then ' 17 = Column Q
If UCase(Cell.Value) = "EXIT" Then
With Worksheets("EXIT")
LastExitRow = .Cells(Rows.Count, "A").End(xlUp).Row
Cell.EntireRow.Copy .Cells(LastExitRow - (.Cells( _
LastExitRow, "A").Value < ""), "A")
Cell.EntireRow.Delete
End With
End If
End If
Next
End Sub

--
Rick (MVP - Excel)


"Jaleel" wrote in message
...
I have an Excel workbook with 2 sheets namely EMP REG and EXIT with more
than
400 rows. When employees are going exit I will enter EXIT in Column Q of
Sheet EMP REG. My idea is when I enter EXIT in Column Q that entire row
must
be cut from EMP REG and pasted in the last blank row of Sheet EXIT. Can
this
be achieved with some code? Thanks in advance.

Jaleel


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot run Macro created in 2003 Gizmo Excel Discussion (Misc queries) 4 June 17th 08 04:28 PM
What may cause macro modules to be created by accident? herrdue Excel Worksheet Functions 2 July 16th 07 06:02 PM
Datestamping a file created by a macro michaelberrier Excel Discussion (Misc queries) 2 June 1st 06 12:41 AM
Macro run each time a new workbook created cmorton89 Excel Discussion (Misc queries) 0 March 8th 06 07:58 PM
Format a Comment created by a Macro Ken G. Excel Discussion (Misc queries) 3 August 30th 05 07:28 AM


All times are GMT +1. The time now is 10:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"