Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 5
Default Trying to do a refresh type function

Hi,

I am trying to sort a timesheet spreadsheet for my work.
What I am after is simple in itself but with the guys I work with I need to make it simpler.
What I want to do is 'cut' the table (weekly timesheet) from sheet 1 and 'paste' it to the top of sheet 2. Meanwhile in sheet 1 the table below the now 'cut' table moves up to the top of the page. While the tables in sheet 2 move down for the new 'pasted' table.
The catch is, I would like there to be a 'refresh' button to do this. That way the boss can click refresh once he has reviewed the tables. So each week, he goes in, ckecks it out, hits refresh and the cut and paste happen. Then repeat the following week.
Is this at all posible?

Thanks in advance for any help given.
  #2   Report Post  
Member
 
Location: Bangalore
Posts: 41
Thumbs up

Quote:
Originally Posted by tame06 View Post
Hi,

I am trying to sort a timesheet spreadsheet for my work.
What I am after is simple in itself but with the guys I work with I need to make it simpler.
What I want to do is 'cut' the table (weekly timesheet) from sheet 1 and 'paste' it to the top of sheet 2. Meanwhile in sheet 1 the table below the now 'cut' table moves up to the top of the page. While the tables in sheet 2 move down for the new 'pasted' table.
The catch is, I would like there to be a 'refresh' button to do this. That way the boss can click refresh once he has reviewed the tables. So each week, he goes in, ckecks it out, hits refresh and the cut and paste happen. Then repeat the following week.
Is this at all posible?

Thanks in advance for any help given.
Hi,

The trick involves identifying the top non empty cell in sheet 1 and the bottom non empty cell in the sheet2.

Once you have identified the top non empty cell (start point of the new table) use the currentregion property (which will select the entire block of contiguous columns and rows, i.e. the table). Cut the selection.
Go to table 2 look for the last row where there is any data available. Go 1 row down this will be the place you will paste the cut table from sheet 1. You put the whole process in a loop which will continue running until it finds no tables left in Sheet1 to be cut and pasted into Sheet2.

Does it sound like a plan? I am assuming you are able to write the equivalent VBA code but if that's not the case please let me know and I can assist you with the VBA code as well.

Thanks
Prashant
  #3   Report Post  
Junior Member
 
Posts: 5
Default

First of all thanks for the reply. This sounds like what I am after.
however, I am a nube and don't know VBA but I think I know what you're talking about. How would I go about doing this?




Quote:
Originally Posted by jack_n_bub View Post
Hi,

The trick involves identifying the top non empty cell in sheet 1 and the bottom non empty cell in the sheet2.

Once you have identified the top non empty cell (start point of the new table) use the currentregion property (which will select the entire block of contiguous columns and rows, i.e. the table). Cut the selection.
Go to table 2 look for the last row where there is any data available. Go 1 row down this will be the place you will paste the cut table from sheet 1. You put the whole process in a loop which will continue running until it finds no tables left in Sheet1 to be cut and pasted into Sheet2.

Does it sound like a plan? I am assuming you are able to write the equivalent VBA code but if that's not the case please let me know and I can assist you with the VBA code as well.

Thanks
Prashant
  #4   Report Post  
Member
 
Location: Bangalore
Posts: 41
Default

Quote:
Originally Posted by tame06 View Post
First of all thanks for the reply. This sounds like what I am after.
however, I am a nube and don't know VBA but I think I know what you're talking about. How would I go about doing this?
Hi,

Good to know that this was helpful.

Are you able to send me a sample spreadsheet - I just don't want to make guesses and ending you up with updating my VBA. I will provide you with the equivalent VBA.

Thanks,
Prashant
  #5   Report Post  
Junior Member
 
Posts: 5
Default

Again, much appreciated. Attached is the relevant spreadsheet.
So what I am after is each time my boss reviews the spreadsheet, he can hit a refresh button or something and the top table from sheet 1 gets posted in sheet 2 and the next table in sheet 1 moves to the top of the page.

cheers


Quote:
Originally Posted by jack_n_bub View Post
Hi,

Good to know that this was helpful.

Are you able to send me a sample spreadsheet - I just don't want to make guesses and ending you up with updating my VBA. I will provide you with the equivalent VBA.

Thanks,
Prashant
Attached Files
File Type: zip TEMPLATE_17102012.zip (59.2 KB, 41 views)


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Trying to do a refresh type function

Hello,

Looking at the template, each table seems to have the same number of rows. If you can rely on the data to always contain the same number of rows, then this code will work fine:

Sub MoveToSummary()

Sheet1.Range("1:25").Cut Sheet2.Range("A1")
Sheet1.Range("2:25").Delete

End Sub

Otherwise, the following code is a bit more flexible:

Sub MoveToSummary()
Dim rTable As Range

Set rTable = Sheet1.Range("C1").End(xlDown).CurrentRegion
rTable.EntireRow.Cut Sheet2.Range("A2")
rTable.EntireRow.Delete

End Sub

Hopefully one of these methods will work out for you.

Ben
  #7   Report Post  
Junior Member
 
Posts: 5
Default

Hi Ben,

The second code works real well. But is it possible to 'insert' the newly cut table as opposed to paste?
That way the previously cut table shifts down a few rows?

Many thanks.

Quote:
Originally Posted by Ben McClave View Post
Hello,

Looking at the template, each table seems to have the same number of rows. If you can rely on the data to always contain the same number of rows, then this code will work fine:

Sub MoveToSummary()

Sheet1.Range("1:25").Cut Sheet2.Range("A1")
Sheet1.Range("2:25").Delete

End Sub

Otherwise, the following code is a bit more flexible:

Sub MoveToSummary()
Dim rTable As Range

Set rTable = Sheet1.Range("C1").End(xlDown).CurrentRegion
rTable.EntireRow.Cut Sheet2.Range("A2")
rTable.EntireRow.Delete

End Sub

Hopefully one of these methods will work out for you.

Ben
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Trying to do a refresh type function

Sure thing. This worked for me.

Sub MoveToSummary()
Dim rTable As Range

Set rTable = Sheet1.Range("C1").End(xlDown).CurrentRegion
Sheet2.Range("2:2").Insert
rTable.EntireRow.Cut
Sheet2.Range("2:2").Insert
rTable.EntireRow.Delete

End Sub
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
What is the bar and function name for refresh all? Eric Excel Programming 1 March 20th 10 11:19 AM
change chart type on pivot refresh BorisS Excel Programming 9 October 7th 06 01:26 AM
VBA Function not refresh tzcarmy[_8_] Excel Programming 5 March 30th 06 02:39 PM
function values do not refresh Jacob Excel Worksheet Functions 2 April 1st 05 09:51 PM
Function and needing to Refresh Mike Excel Programming 2 December 24th 03 04:22 PM


All times are GMT +1. The time now is 10:30 PM.

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"