View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
jason jason is offline
external usenet poster
 
Posts: 104
Default update one sheet with VBA from another sheet

Rene,

Make the range("A20:A30") a named range e.g "myRange" then in the VBE
editor window, in the projest explorer section(left hand side),
double-click on the worksheet that you wish to update automatically,
at the top of the right hand code window there are two small windows
with dropdowns - in the left hand select "worksheet"and in the right
hand one select "Activate"

Then enter the code below:

Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
Sheets("Sheet2").[A20:A30].Copy [myrange]
Application.ScreenUpdating = True
End Sub

This will rely upon the new sheet always being positioned as the 2nd
sheet in the book.If the latest sheet was always the last in the book
you could use:

Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
Sheets(Sheets.Count).[A20:A30].Copy [myrange]
Application.ScreenUpdating = True
End Sub

Not sure if this helps at all

Jason


René Kerstgens wrote in message . ..
Does anyone know how to update (replace contents of )a range with the
content of another sheets. In fact:

A have a sheet with in column A range 20 till 30 a range of names. The
name of the sheet differs every week according to the weeknumber. In
another sheet i have the new names en while opening this recent sheet
i want it to lookup the most recent weeksheet and open it and replace
the contents with the most recent one.

Has anyone an idea how to do this.

Thanks in advance

René Kerstgens