syntax help

  • Thread starter Thread starter Blue
  • Start date Start date
B

Blue

I have the following code, what syntax do I put to paste sgm value in the
selected cell?

Sub findsqm()

Dim sqm As Long
sqm = Range("K1").Value

(Code in here to open another spreadsheet and find a particular cell)

Cells(ActiveCell.Row, ActiveCell.column + 1).Select

syntax to past sgm value in selected cell

End Sub


Thanks, Brain Dead Blue
 
You can just put:
Cells(ActiveCell.Row, ActiveCell.column + 1) = sgm
You don't need to select the destination cell. If you want to select it
first, put:
ActiveCell = sgm

HTH Otto
 
Hi

Problem is, there's only one Active whatever, and once you open or select
something Active whatever changes. "Object oriented programming" is really
helpful here, see if the following is getting you somewhere:

Sub test()
Dim RngOne As Range
Dim RngTwo As Range
Dim WB As Workbook

'lock current location as an absolute:
Set RngOne = ActiveCell

'change path to Read file, open it:
Set WB = Workbooks.Open("C:\temp\Book1.xls")

'replace with your "code here" magic:
Set RngTwo = WB.Sheets(1).Cells(1, 1)

'paste:
RngOne.Offset(1, 0).Value = RngTwo.Value

'close:
WB.Saved = True
WB.Close

End Sub

HTH. Best wishes Harald
 

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