PC Review


Reply
Thread Tools Rate Thread

Auto Update a sheet through Macro

 
 
Chetu
Guest
Posts: n/a
 
      7th Aug 2009
Hi,

I have Sheet 1 where the user enters the data of a particulra product,
Sheet 2 is linked to Sheet 1 with lot of formulas ( basically for
analysis). I link the Sheet 2 with sheet 1 through formulas. I dont
want to copy the formulas to the entire Sheet 2 since that will
increase the size.

Can anyone suggest me a Macro , Below is the steps for your
understanding

1) When user enters 10 new entries, the sheet 2 should copy the
formulas in the last row and extend the same to 10 rows ( this will
update the new data)

2) The macro shoudl apply the formula by copying the last row in sheet
2 and then paste the formulas only to the number of new updates in
Sheet 1.

Regards
Chetan J
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      7th Aug 2009
the code below will add the rows add, clear the empty cells, and leave the
formulas

"Simon Lloyd" wrote:

>
> What would be the ranges used? where will the entries be? all in the
> same column?, where are the formulae that you want extending, sheet 1 or
> sheet 2?
>
> I don't understand your 2 points in point 1 you say "sheet2 should copy
> the formula in the last row.....etc but in point 2 you say you want the
> same formulae pasting to sheet1? can you clarify what it is you are
> trying to achieve?
>
> Chetu;444768 Wrote:
> > Hi,
> >
> > I have Sheet 1 where the user enters the data of a particulra product,
> > Sheet 2 is linked to Sheet 1 with lot of formulas ( basically for
> > analysis). I link the Sheet 2 with sheet 1 through formulas. I dont
> > want to copy the formulas to the entire Sheet 2 since that will
> > increase the size.
> >
> > Can anyone suggest me a Macro , Below is the steps for your
> > understanding
> >
> > 1) When user enters 10 new entries, the sheet 2 should copy the
> > formulas in the last row and extend the same to 10 rows ( this will
> > update the new data)
> >
> > 2) The macro shoudl apply the formula by copying the last row in sheet
> > 2 and then paste the formulas only to the number of new updates in
> > Sheet 1.
> >
> > Regards
> > Chetan J

>
>
> --
> Simon Lloyd
>
> Regards,
> Simon Lloyd
> 'Microsoft Office Help' (http://www.thecodecage.com)
> ------------------------------------------------------------------------
> Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=123316
>
>

 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      7th Aug 2009
The last code I gave put the new rows in front of the last row. this code
puts them after the last row. I usually like keeps the last row.

Sub AddRows()

LastRow = Range("A" & Rows.Count).End(xlUp).Row
For Count = 1 To 10
Rows(LastRow).Copy
Rows(LastRow).Insert
Next Count
LastCol = Cells(LastRow, Columns.Count) _
.End(xlToLeft).Column
For Colcount = 1 To LastCol
'if not a formula clear the cell
If Left(Cells(LastRow + 1, Colcount).Formula, 1) <> "=" Then
Range(Cells(LastRow + 1, Colcount), _
Cells(LastRow + 10, Colcount)).ClearContents
End If
Next Colcount

End Sub


"Simon Lloyd" wrote:

>
> What would be the ranges used? where will the entries be? all in the
> same column?, where are the formulae that you want extending, sheet 1 or
> sheet 2?
>
> I don't understand your 2 points in point 1 you say "sheet2 should copy
> the formula in the last row.....etc but in point 2 you say you want the
> same formulae pasting to sheet1? can you clarify what it is you are
> trying to achieve?
>
> Chetu;444768 Wrote:
> > Hi,
> >
> > I have Sheet 1 where the user enters the data of a particulra product,
> > Sheet 2 is linked to Sheet 1 with lot of formulas ( basically for
> > analysis). I link the Sheet 2 with sheet 1 through formulas. I dont
> > want to copy the formulas to the entire Sheet 2 since that will
> > increase the size.
> >
> > Can anyone suggest me a Macro , Below is the steps for your
> > understanding
> >
> > 1) When user enters 10 new entries, the sheet 2 should copy the
> > formulas in the last row and extend the same to 10 rows ( this will
> > update the new data)
> >
> > 2) The macro shoudl apply the formula by copying the last row in sheet
> > 2 and then paste the formulas only to the number of new updates in
> > Sheet 1.
> >
> > Regards
> > Chetan J

>
>
> --
> Simon Lloyd
>
> Regards,
> Simon Lloyd
> 'Microsoft Office Help' (http://www.thecodecage.com)
> ------------------------------------------------------------------------
> Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=123316
>
>

 
Reply With Quote
 
Chetan
Guest
Posts: n/a
 
      7th Aug 2009
On Aug 7, 1:14*pm, Simon Lloyd <Simon.Lloyd.3wj...@thecodecage.com>
wrote:
> What would be the ranges used? where will the entries be? all in the
> same column?, where are the formulae that you want extending, sheet 1 or
> sheet 2?
>
> I don't understand your 2 points in point 1 you say "sheet2 should copy
> the formula in the last row.....etc but in point 2 you say you want the
> same formulae pasting to sheet1? can you clarify what it is you are
> trying to achieve?
>
> Chetu;444768 Wrote:
>
>
>
>
>
> > Hi,

>
> > I have Sheet 1 where the user enters the data of a particulra product,
> > Sheet 2 is linked to Sheet 1 with lot of formulas ( basically for
> > analysis). I link the Sheet 2 with sheet 1 through formulas. I dont
> > want to copy the formulas to the entire Sheet 2 since that will
> > increase the size.

>
> > Can anyone suggest me a Macro , Below is the steps for your
> > understanding

>
> > 1) When user enters 10 new entries, the sheet 2 should copy the
> > formulas in the last row and extend the same to 10 rows ( this will
> > update the new data)

>
> > 2) The macro shoudl apply the formula by copying the last row in sheet
> > 2 and then paste the formulas only to the number of new updates in
> > Sheet 1.

>
> > Regards
> > Chetan J

>
> --
> Simon Lloyd
>
> Regards,
> Simon Lloyd
> 'Microsoft Office Help' (http://www.thecodecage.com)
> ------------------------------------------------------------------------
> Simon Lloyd's Profile:http://www.thecodecage.com/forumz/member.php?userid=1
> View this thread:http://www.thecodecage.com/forumz/sh....php?t=123316- Hide quoted text -
>
> - Show quoted text -


Hi Lloyd,

Sorry for the confusion,

Actually Sheet 1 is used by the user, But Sheet 2 is linked to Sheet
1, So Sheet 2 has formulas starting range from B12 to DN12 ( like
refering sheet1 and also some other formulas for analysis), I want a
macro which copies the B12 to DN12 row and pastes them in B13 to DN13,
once the formulas are copied, the formulas will automatically fetch
the data from Sheet 1.

But the problem is, If a user enters data in 10 new ros in Sheet1, The
same should reflect in Sheet2 ( I know i can copy paste the formulas,
but this method increases the file size ).
 
Reply With Quote
 
Joel
Guest
Posts: n/a
 
      7th Aug 2009
'put this code in the sheet2 VBA page so when the sheet is selected the
formulas get updated

Private Sub Worksheet_Activate()
Sh2LastRow = Range("A" & Rows.Count).End(xlUp).Row

With Sheets("Sheet1")
Sh1LastRow = .Range("A" & Rows.Count).End(xlUp).Row
End With

If Sh1LastRow > Sh2LastRow Then
Rows(Sh2LastRow).Copy _
Destination:=Rows(Sh2LastRow & ":" & Sh1LastRow)
End If
End Sub

"Chetan" wrote:

> On Aug 7, 1:14 pm, Simon Lloyd <Simon.Lloyd.3wj...@thecodecage.com>
> wrote:
> > What would be the ranges used? where will the entries be? all in the
> > same column?, where are the formulae that you want extending, sheet 1 or
> > sheet 2?
> >
> > I don't understand your 2 points in point 1 you say "sheet2 should copy
> > the formula in the last row.....etc but in point 2 you say you want the
> > same formulae pasting to sheet1? can you clarify what it is you are
> > trying to achieve?
> >
> > Chetu;444768 Wrote:
> >
> >
> >
> >
> >
> > > Hi,

> >
> > > I have Sheet 1 where the user enters the data of a particulra product,
> > > Sheet 2 is linked to Sheet 1 with lot of formulas ( basically for
> > > analysis). I link the Sheet 2 with sheet 1 through formulas. I dont
> > > want to copy the formulas to the entire Sheet 2 since that will
> > > increase the size.

> >
> > > Can anyone suggest me a Macro , Below is the steps for your
> > > understanding

> >
> > > 1) When user enters 10 new entries, the sheet 2 should copy the
> > > formulas in the last row and extend the same to 10 rows ( this will
> > > update the new data)

> >
> > > 2) The macro shoudl apply the formula by copying the last row in sheet
> > > 2 and then paste the formulas only to the number of new updates in
> > > Sheet 1.

> >
> > > Regards
> > > Chetan J

> >
> > --
> > Simon Lloyd
> >
> > Regards,
> > Simon Lloyd
> > 'Microsoft Office Help' (http://www.thecodecage.com)
> > ------------------------------------------------------------------------
> > Simon Lloyd's Profile:http://www.thecodecage.com/forumz/member.php?userid=1
> > View this thread:http://www.thecodecage.com/forumz/sh....php?t=123316- Hide quoted text -
> >
> > - Show quoted text -

>
> Hi Lloyd,
>
> Sorry for the confusion,
>
> Actually Sheet 1 is used by the user, But Sheet 2 is linked to Sheet
> 1, So Sheet 2 has formulas starting range from B12 to DN12 ( like
> refering sheet1 and also some other formulas for analysis), I want a
> macro which copies the B12 to DN12 row and pastes them in B13 to DN13,
> once the formulas are copied, the formulas will automatically fetch
> the data from Sheet 1.
>
> But the problem is, If a user enters data in 10 new ros in Sheet1, The
> same should reflect in Sheet2 ( I know i can copy paste the formulas,
> but this method increases the file size ).
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - Auto - Sheet Name change ? expiry Som Microsoft Excel Misc 3 21st Mar 2009 03:39 AM
How to auto run a macro in actived sheet? =?Utf-8?B?VHZuZ3V5ZQ==?= Microsoft Excel Discussion 7 12th Jan 2006 12:50 AM
Auto Update Sheet Tab =?Utf-8?B?S2FyZW4=?= Microsoft Excel Worksheet Functions 3 16th May 2005 08:11 PM
Auto Execute Macro on Sheet Pete Microsoft Excel Discussion 2 18th Aug 2004 04:01 PM
auto name sheet w/ macro or function laneman Microsoft Excel Programming 6 8th Jul 2004 11:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:33 AM.