View Single Post
  #14   Report Post  
KeriM KeriM is offline
Member
 
Posts: 70
Default

Quote:
Originally Posted by KeriM View Post
John,

Perfect! It does the calculation and writes it on the source worksheet.

Now, how can I get it write to another workbook? This one may be a bit tricker, because the workbook I want to write to doesn't always have the same name (it is always open though). This is how it is written (and working) for my other sheets:

Code:
Dim ws As Workbook
If ws.Name Like "*Count*" Then
Windows(ws.Name).Select
    Range("C3").Select
    ActiveCell.FormulaR1C1 = 'write answer here'
When I tried to implement this code into yours, it was posting a value of 0, probably because it lost the values when I switched sheets. Can I store the answer in a variable and then call the variable to write the answer in the cell?
Update: tried it again, it works!

Code:
For i = 1 To 700
If InStr(Cells(i, 2), "a") And InStr(Cells(i, 3), "1") Then
num = Cells(i, 5) - Cells(i, 6)
For Each ws In Workbooks
If ws.Name Like "*Count*" Then Windows(ws.Name).Activate
Next
Range("C3").Select
ActiveCell.FormulaR1C1 = num
End If
Next i
Thanks so much for your help John!