Cells selection

maximus4004

New Member
Joined
Jun 2, 2011
Messages
5
Hi,

I want to select cells when the range is under a certain number(<=0) and return value from other cells.

My problem is more how to use the proper syntax.

HTML:
exemple:
If Range("J2:J44") >=0
    'Then ActiveCell = Select
'and return value in cell ("B2, C2") for each row.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Im confused, you want both b2 and c2 returned in every cell in the range J2:J44, if this range is >= 0?
Code:
Sub Beefy()

Dim i as integer

For i = 2 to 44

If range("J" & i).Value >= 0 Then
   Range("J" & i).FormulaR1C1 = "=R2C2&R2C3"

End IF

Next i

End Sub
 
Last edited:
Upvote 0
The macro I wrote works as follows:

Example--

B2=beef
C2=cake

Put random numbers in J2:J44, but leave a couple blank.

Run the macro.

All cells in J2:j44 that previously had numbers will now say beefcake.
 
Upvote 0
Hi Colombus

Thank you for the quick response. I try and it works.

I'd be more specific about my request.



Code:
If my CELLS <=0 in range ("J2:J44") = true

then return the value in colums "B" and "C" in that row

and concatenante them for one selection value.


I appreciate your help
 
Upvote 0
This isn't the best way of doing this, but it should let you see the syntax (I hope! :biggrin:)

Code:
Sub Ridic()

Dim i As Integer

For i = 2 To 44

If Range("J" & i).Value < 0 Or Range("J" & i).Value = "" Then
    Range("J" & i).Value = Range("J" & i).Value
Else
   Range("J" & i).FormulaR1C1 = "=RC[-8]&RC[-7]"
   
End If

Next i

End Sub


What this says is:

If any cell in the range J2:J44 is blank, or less than 0, do nothing.

If any cell in the range J2:J44 is greater than or equal to 0, or has text, combine the values of B and C in that row into the corresponding cell in Column J.
 
Last edited:
Upvote 0
My value in "J" range is numerical and he give my quantity I will need to order.

My other cells are the PART # and LAMP # code I need to order.

When I need to place a order, that will give me e-mail with proper code to order.
 
Upvote 0
How do you want your part # and lamp # to be joined?

For instance:

Part Number = 1234
Lamp Number = 5678

Current macro combines them as "12345678"

Could alter the line

Range("J" & i).FormulaR1C1 = "=RC[-8]&RC[-7]"

To make 1234-5678, 1234/5678, 1234 5678, Part # 1234/Lamp # 5678, etc... anything you want really.
</pre>
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top