LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Member
 
Posts: 70
Default

Quote:
Originally Posted by John Keith View Post
As usual there are many ways to address the next requirements for
testing the cell contents as you describe below. But the simplest
solution I would use would be to test the cell to see if it contains
"a" or "1" by using the instr function like this:

For i = first_row to last_row
if instr(cells(i, "B")',"a")0 and instr(cells(i, "C"),"1")0 then _
worksheets(othersheet).cells(i, "A")= cells(i, "E") - cells(i, "F")
Next i

The second line in the loop will store your result in the same row on
the target sheet as the source sheet.

For only 400 lines of data the for loop will be very fast.
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?

Last edited by KeriM : August 17th 12 at 09:18 PM Reason: Added information, shortened quote
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Coult not find specified object" and "Path-File access error" messages Robert Crandal Excel Programming 3 December 19th 09 09:12 PM
Whats wrong with this? MyWBAccRep.Sheets("Volumes").Cells.Find("latest").Copy.Offset(0, Simon[_2_] Excel Programming 2 August 11th 08 01:29 PM
find "Cancellation" in column "A" and copy all data from Columns B-F onto another Sheet bjohnson Excel Programming 1 September 20th 07 04:02 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM


All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"