Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro to take selected cells times a selected cell

I have a row of hardcoded numbers in cells A1, A2, A3 A4. I want to be able
to highlight(select) the above cells and have them be multiplied by B2. Is
this possible.

I have a huge worksheet that has all hardcoded numbers that I need to be
multiplied by a certain cell. In the above instance B2.

So instead of going into each cell, placing an "=" in front of the value and
then putting an * B2 at the end of the value in each cell, I am trying to
figure out how set up a macro and do it automatically.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Macro to take selected cells times a selected cell

Sub MultiplyByB2()
Dim cell As Range

For Each cell In Selection
If IsNumeric(cell.Value) Then
cell.Formula = "=" & cell.Value & "*B2"
End If
Next cell
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Craig" wrote in message
...
I have a row of hardcoded numbers in cells A1, A2, A3 A4. I want to be

able
to highlight(select) the above cells and have them be multiplied by B2.

Is
this possible.

I have a huge worksheet that has all hardcoded numbers that I need to be
multiplied by a certain cell. In the above instance B2.

So instead of going into each cell, placing an "=" in front of the value

and
then putting an * B2 at the end of the value in each cell, I am trying to
figure out how set up a macro and do it automatically.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Macro to take selected cells times a selected cell

Craig

Sub test()
Dim ocell As Range
For Each ocell In Selection
ocell.Value = ocell.Value * Range("B2").Value
Next ocell
End Sub

Manually you can select B2 and copy.

Then select all the cells to change and paste specialmultiplyOKEsc


Gord Dibben Excel MVP

On Sun, 23 Oct 2005 17:56:12 -0500, "Craig" wrote:

I have a row of hardcoded numbers in cells A1, A2, A3 A4. I want to be able
to highlight(select) the above cells and have them be multiplied by B2. Is
this possible.

I have a huge worksheet that has all hardcoded numbers that I need to be
multiplied by a certain cell. In the above instance B2.

So instead of going into each cell, placing an "=" in front of the value and
then putting an * B2 at the end of the value in each cell, I am trying to
figure out how set up a macro and do it automatically.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro to take selected cells times a selected cell

Thanks! Exactly what I needed!


"Bob Phillips" wrote in message
...
Sub MultiplyByB2()
Dim cell As Range

For Each cell In Selection
If IsNumeric(cell.Value) Then
cell.Formula = "=" & cell.Value & "*B2"
End If
Next cell
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Craig" wrote in message
...
I have a row of hardcoded numbers in cells A1, A2, A3 A4. I want to be

able
to highlight(select) the above cells and have them be multiplied by B2.

Is
this possible.

I have a huge worksheet that has all hardcoded numbers that I need to be
multiplied by a certain cell. In the above instance B2.

So instead of going into each cell, placing an "=" in front of the value

and
then putting an * B2 at the end of the value in each cell, I am trying to
figure out how set up a macro and do it automatically.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Macro to take selected cells times a selected cell

Thanks for the help!


"Gord Dibben" <gorddibbATshawDOTca wrote in message
...
Craig

Sub test()
Dim ocell As Range
For Each ocell In Selection
ocell.Value = ocell.Value * Range("B2").Value
Next ocell
End Sub

Manually you can select B2 and copy.

Then select all the cells to change and paste specialmultiplyOKEsc


Gord Dibben Excel MVP

On Sun, 23 Oct 2005 17:56:12 -0500, "Craig" wrote:

I have a row of hardcoded numbers in cells A1, A2, A3 A4. I want to be
able
to highlight(select) the above cells and have them be multiplied by B2.
Is
this possible.

I have a huge worksheet that has all hardcoded numbers that I need to be
multiplied by a certain cell. In the above instance B2.

So instead of going into each cell, placing an "=" in front of the value
and
then putting an * B2 at the end of the value in each cell, I am trying to
figure out how set up a macro and do it automatically.




Reply
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
Multiple cells or columns are selected instead of selected cell or Mikey Excel Discussion (Misc queries) 1 April 29th 09 09:48 PM
Cells are selected but aren't displayed as selected Nifty Excel Discussion (Misc queries) 2 September 17th 06 07:22 PM
Cells are selected but aren't displayed as selected Nifty Excel Worksheet Functions 0 September 17th 06 11:34 AM
Copy Selected cells down a row with macro DB33 Excel Discussion (Misc queries) 1 February 15th 06 05:33 PM
Macro to format selected cells BeSmart[_2_] Excel Programming 4 May 7th 04 01:28 PM


All times are GMT +1. The time now is 03:39 PM.

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

About Us

"It's about Microsoft Excel"