Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

4 CHOICES INTO ONE CELL 2

Status
Not open for further replies.

Harley78

Electrical
May 8, 2007
77
You can see that I am trying to fill a cell on another worksheet, but with this code, it always ends up blank because A145 is blank. How do I keep this from happening?

Range("A139").Copy Destination:=Sheets(1).Cells(279, 1)
Range("A141").Copy Destination:=Sheets(1).Cells(279, 1)
Range("A143").Copy Destination:=Sheets(1).Cells(279, 1)
Range("A145").Copy Destination:=Sheets(1).Cells(279, 1)
 
Replies continue below

Recommended for you

You are copying a null value into Cells(279, 1). Why would you expect anything other than null?
 
As your title says, you're copying 4 results to the same cell, so the last copy is the one you see. Why would you expect otherwise?

TTFN

FAQ731-376
 
your exactly right and I know that. But if I say...I put a number in Cell A143 i want that number to go Sheet one Row 279 Column A. But as you said, it will look at the last macro. So I am trying to make a macro that will look at all four and input the highest number
 
I'm not trying to be mean, but you're really not providing us much information in your original question with which to help you. Nowhere in your original post did you say that you wanted to pick the highest number out of those few cells.

For starters, if this is all you want to accomplish then there's no need for a macro. Just use the MAX() function of Excel. The formula in Sheet 1 Row 279 Column A would be

MAX('WhateverYourSourceSheetNameIs'!A139:A145)

If you really want to do this in code, then use the line

Sheets(1).Cells(279, 1).Value = Application.WorksheetFunction.Max(Range("A139:A145"))

Having Excel cut and paste through code is rarely the most efficient way to go.
 
I agree handleman... an important notation in which I did not provide. Sorry about that and thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor