LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Help with tidying up code please


I have a table on a worksheet, there will be several of these tables
(one for each project) one after the other on the worksheet, the first
row contains the 'Name of Project' at Column A. In column D of the
first row is the Insert Row button.

Row 2 is headings for the table.

Row 3 is where the data starts.

The code works well , in that it uses
Range(ActiveSheet.Buttons(Application.Caller).TopL eftCell.Address).Select
to work out where the macro is being called from, it then stores name of
the project in strName.

The code then inserts a row at Row3 just below the headings, doing this
takes the formatting from the heading rows, so the code copies the row
below and pastes over the new row at Row 3.

Clears the contents and then inserts the date in the first cell of the
new row and the project name in the second cell of the new row.

It does all i want it to do, I was just wondering if their is any
tidying up i could do.

Also, whenever I use activecell.offset I always include Range("A1"), is
this necessary and what does it mean, from looking at vba help,
including Range("A1") means a ref to cell A1, but that does not seem to
be the case.

Any pointers you can give me on the code would be appreciated, always
like to learn new ways of coding something.

Sub InsertRow()

Dim myDate As Date
Dim MyStr As String
Dim strName As String

Application.ScreenUpdating = False

myDate = Date
MyStr = Format(myDate, "mmm yy")


Range(ActiveSheet.Buttons(Application.Caller).TopL eftCell.Address).Select

strName = ActiveCell.Offset(0, -4).Range("A1").Value

ActiveCell.Offset(2, 0).Range("A1").Select
Selection.EntireRow.Insert
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Selection.Copy
ActiveCell.Offset(-1, 0).Range("A1").Select
ActiveSheet.Paste
Selection.ClearContents
With ActiveCell
.Value = myDate '(dd / mm / yyyy)
.Offset(0, 1) = strName
.Select
End With
End Sub
 
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
Tidying up workbook (and pivot table help)... AlbertKJ Excel Discussion (Misc queries) 1 January 7th 12 02:08 AM
Need help tidying up a report alexm999 Excel Discussion (Misc queries) 2 March 2nd 06 02:51 PM
Help Tidying up formula Paul Excel Worksheet Functions 3 January 13th 06 04:55 PM
tidying up code and refering macros philbennison Excel Programming 0 July 12th 05 01:32 PM
tidying up VBA Chris Excel Programming 1 December 23rd 04 01:42 PM


All times are GMT +1. The time now is 10:36 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"