Z
zulfer7
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
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