Thread: Loop in Excel
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default Loop in Excel

This goes in the ThisWorkbook code module. Open the VBE and in the Project
pane, double click on ThisWorkbook to open the code module then copy and
paste this code into it.

Private Sub Workbook_Open()
If Weekday(Date) < 2 Then
Exit Sub
ElseIf Range("IV1") = Date Then '<<<Change cell if desired.
Exit Sub
Else
Range("A10").Cut
Range("A1").Insert Shift:=xlDown
Range("IV1") = Date '<<<Change to match the other.
End If
ThisWorkbook.Save
End Sub


I used Range("IV") as the check range so that if the file is opened more
than once a day, it will not change again that day. If first checks to see
if it is Monday, If it is not Monday it exits the procedure without doing
anything.
The requirement for this to work is that your system date is correctly set
and that it uses Sunday as day one of the week.




"Khan" wrote in message
...
In the Column "A" I have 10 Names and In the Column "B" I have
1,2,3........10 (as below) in Excel sheet. I want that every week Last
Name (Ebie) should come at the place of number one (Paul) In the
column A and rest of the all names should go down respectively. Every
week Bottom Name should Come at the place of Top Name. The Column B
will remain the same but name should be change every week
automatically last at the place of first and first at the place of
second and so on. How I can do it in Excell Programming.

Column A Column B

Paul 1
Mick 2
Terry 3
Joan 4
Justin 5
Jim 6
Jo 7
Kay 8
Chuck 9
Ebie 10