Solved

VBA excel, Copy Row to Memory for Later UnDo

Posted on 2011-09-10
5
348 Views
Last Modified: 2012-05-12
I have a form with 3 CommandButtons.  
1. "Copy Row"  Button
2. "Clear Values" Button
3. "UnDo Row" Button

Here are the Click Actions for each Button:

Private Sub Copy_Row_Click()

      ' ....???? Selection.EntireRow ....Copy to Memory ???

End Sub


Private Sub Clear_Values_Click()

          Selection.EntireRow.Clear

End Sub


Private Sub Undo_Row_Click()

  ' ....???? Selection.EntireRow ......bring back the old Row....???..

End Sub

Open in new window



I am trying to find a way so that, when I hit the Button "Copy_Row" and Then Button "Clear Values"  to be able (if I decide at a later stage) to bring the entire cleared Row (with its Values and its Formulas) back to place.....

I am not looking for the standard method of copying the whole file because it is very big and it will slow the procedures down....

Thanks in advance,
Any ideas?

0
Comment
Question by:New_Alex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 500 total points
ID: 36516977
If you only ever wanted to be able to recover the most recently deleted row, you could store its values in a variant array, the restore them later.  But this would only restore values/formulas, not formatting:

Private mvSavedRow

Private Sub Copy_Row_Click()

      ' ....???? Selection.EntireRow ....Copy to Memory ???
      mvSavedRow = Application.Intersect(Selection.EntireRow, ActiveSheet.UsedRange).Formula

End Sub


Private Sub Clear_Values_Click()

          Selection.EntireRow.Clear

End Sub


Private Sub Undo_Row_Click()

  ' ....???? Selection.EntireRow ......bring back the old Row....???..
  Dim rng As Excel.Range
  
  Set rng = Selection.Cells(1)
  rng.Resize(1, UBound(mvSavedRow, 2)).Formula = mvSavedRow

End Sub

Open in new window

0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 36516979
If you wanted formats and everything, you would probably have to copy the row to another (hidden?) sheet, then copy it back again
0
 
LVL 1

Author Comment

by:New_Alex
ID: 36517098
Hi andrew.

Is it possible to save the Row in a closed Workbook file and then retrieve it while workbook remains closed?

Thank you... Presentation is important for me!
0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 36517192
You couldn't save it in a closed workbook - it would have to be open in Excel to write to it and read from it. The first suggestion I made would not show anything to the user. If formatting is important you could possibly copy it from another row.
0
 
LVL 1

Author Closing Comment

by:New_Alex
ID: 36540789
Yes very good solution but limited. There are probably not a lot of things you can do generally for this
0

Featured Post

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question