Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Assigning Selected Cells to Code

I wish to onscreen (example only) select (highlight) say B5:B7, then (with
control key down) then select C10:C11; then run a macro that will produce a
MsgBox with:

"The Difference is 1,234.50"

B5 = 1,111.00
B6 = 2,222.00
B7 = 3,333.00 where B5:B7 total 6,666,00

and
C10 = 2,500.00
C11 = 2,931.50 where C10:C11 totals 5,431.50

Any help appreciated,,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Assigning Selected Cells to Code

I think you have to split it up. Test this hastily mixed code:

Add a form to your testsheet and a CommandButton1 in the form. In the
CommandButton1_Click() kode, add the following:

----------
Dim Info1 As String
Dim HoldRange
Dim i As Integer

For i = 1 To 2
Info1 = "Select the cells to include." & vbCrLf
Set userRange = Application.InputBox(prompt:=Info1, Title:="Calculate",
Type:=8)

HoldRange = userRange.Address
Set userRange = Range(HoldRange)

Range(HoldRange).Select

Cells(2 + i, 2).Formula = "=SUM(" & HoldRange & ")"

Next i

ssum = Cells(3, 2).Value - Cells(4, 2).Value

MsgBox (ssum)

Unload Me
Canceled:

---------
Take notice that the values are placed in Col B and that it seems you'll
have to use the mouse to select the cells.

Regards Birger

"JMay" skrev i en meddelelse
news:TSaSa.1928$If5.1696@lakeread06...
I wish to onscreen (example only) select (highlight) say B5:B7, then (with
control key down) then select C10:C11; then run a macro that will produce

a
MsgBox with:

"The Difference is 1,234.50"

B5 = 1,111.00
B6 = 2,222.00
B7 = 3,333.00 where B5:B7 total 6,666,00

and
C10 = 2,500.00
C11 = 2,931.50 where C10:C11 totals 5,431.50

Any help appreciated,,




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
Finding a single word match in a text string and assigning a code Morton Detwyler[_2_] Excel Worksheet Functions 6 September 15th 09 09:18 PM
Multiple cells or columns are selected instead of selected cell or Mikey Excel Discussion (Misc queries) 1 April 29th 09 09:48 PM
In VBA, how do you format selected code all at once? LunaMoon Excel Discussion (Misc queries) 2 July 28th 08 02:16 AM
VBA Code when a cell is selected [email protected] Excel Discussion (Misc queries) 3 June 13th 07 08:50 PM
deleting selected worksheets using vb code George Excel Discussion (Misc queries) 1 October 31st 06 05:14 PM


All times are GMT +1. The time now is 01:41 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"