View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Simon Lloyd[_1061_] Simon Lloyd[_1061_] is offline
external usenet poster
 
Posts: 1
Default Placing a regular excel function in VBA code [HOW?]


gordom;263410 Wrote:
Hi everyone.
Im sorry but Im totally illiterate in VBA and have very little
experience in macro (hours only ;). I recorded a macro containing the
following code:

Sub Macro4()
ActiveSheet.PageSetup.PrintArea = "$A$1:$E$34"
End Sub

What I would like to accomplish is to change "$E$34" into a regular
Excel function:

="$E$" & (MATCH ("abc";A1:A40))

(the function looks for "abc" text in A column and returns the address
of the cell in E column in the same row)

Could someone tell me how it can be done? I was looking in Google for a
while but without success. Thanks in advance,
gordom

Something like:

Sub Macro4()
ActiveSheet.PageSetup.PrintArea = "$A$1:$E$" &
Application.WorksheetFunction.(MATCH
("abc",Activesheet.Range("A1:A40"))).Address
End Sub

Not tested but you get the idea!


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (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...ad.php?t=73534