Thread: sub inheritance
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cako Cako is offline
external usenet poster
 
Posts: 2
Default sub inheritance

hi,

i wanted to write a few macros to perform some of the routine
maintenance on a fairly large workbook, and look at actually creating
parts of it.

The required tasks, formatting / update of formulae are not quite the
same but have many similarities, and so I thought i'd write subs for
the common tasks which would be called where they are needed, and
write the unique stuff in a sub for each sheet. then all of these
would be called up by a master sub.

I'd like to aim to minimise the number of variables passed, ideally
I'd do this:

Sub withthis()
Dim sWB as string
sWB = ActiveWorkbook.name
With Workbooks(sWB).Sheets(2)
WriteToCells iRow:=5, iCol:=5, sValue:="will this work?"
End With
End Sub

Sub WriteToCellsiRow As Integer, iCol As Integer, sValue As String)
.Cells(iRow, iCol) = sValue
End Sub

but instead it looks like i will need to pass the sheet name each
time, which means I will refer to it once when the sheet specific
stuff is being wtitten, next pass it to the sub, which in turn will be
need a with statement. Is that my only option or is there a more
efficient way of doing that? merci beacoup!