Modify function for another workbook

  • Thread starter Thread starter kirkm
  • Start date Start date
K

kirkm

Hi,

I have these 2 functions which let me read/write to a cell.

Sub WriteCell(mSheet, mVal, mCell)
ActiveWorkbook.Worksheets(mSheet).Range(mCell).Value = LTrim(mVal)
End Sub
Function ReadCell(mSheet, mCell)
ReadCell = ActiveWorkbook.Worksheets(mSheet).Range(mCell).Value
End Function

This lets me specify the worksheet, but what if I have/want to use
another workbook?

I presume wookbook is the VBAProject name from the Project window?

Thanks - Kirk
 
No it is the book name

Workbooks("my other book.xls")

instead of activeWorkbook.

Pass it as a parameter like the rest.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
No it is the book name

Workbooks("my other book.xls")

instead of activeWorkbook.

Pass it as a parameter like the rest.

Thanks Bob,

That worked a treat :-)

Cheers - Kirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top