LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Please Help with Short Macro

What I am trying to do with this macro is when run, it will prompt the user
for a range of cells in excel, once selected it needs to take the range (i.e.
A1-C1) and then format the cells as follows, A1,";",B1",";",C1 all within one
cell. It would also be nice to limit the range to a max of 225 cells. I can
see ALOT of people using this macro so any help would be appreciated. This
is what I have so far and it may not be very helpful, I am trying to combine
2 separate macros, one that gets a user range and one that formats the cells
into the proper format.

Sub GetUserRange()
Dim UserRange As Range

Output = 565
Prompt = "Select a cell for the output."
Title = "Select a cell"

' Display the Input Box
On Error Resume Next
Set UserRange = Application.InputBox( _
Prompt:=Prompt, _
Title:=Title, _
Default:=ActiveCell.Address, _
Type:=8) 'Range selection

' Was the Input Box canceled?
If UserRange Is Nothing Then
MsgBox "Canceled."
Else
UserRange.Range("A1") = Output
End If

(THIS IS WHERE THE MACRO STARTS THAT FORMATS THE CELLS CORRECTLY)
x = 1

Cells(5, 2).Value = ""
While Cells(x, 1).Value < ""
Cells(5, 2).Value = Cells(5, 2) & Replace(Cells(x, 1).Value, " ", "") &
";"
x = x + 1
Cells(4, 3).Value = x - 1
Over_Count = Abs(Cells(4, 5))
Wend
Cells(5, 2).Copy

If x C_Value Then
If Over_Count = 1 Then Vals = " value. " Else Vals = " values. "
UserForm1.Label4 = Over_Count & Vals
UserForm1.Show

Else
UserForm2.Show

End If
Finish:


End Sub

 
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
Short Macro Joonas K Excel Discussion (Misc queries) 0 August 7th 08 05:31 PM
ZED - Need a short macro fix [email protected] Excel Discussion (Misc queries) 3 January 19th 07 03:32 PM
Onkey vs Macro Short cut key rgarber50 Excel Discussion (Misc queries) 1 July 10th 05 07:34 PM
Macro short cut key Vispy Excel Programming 1 December 4th 03 06:07 AM
how to enhance this macro (really short) Bob Phillips[_5_] Excel Programming 1 September 9th 03 11:43 PM


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