Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default simple excel VBA programming

I am fairly new to Excel and VBA, I have some VBA
background in Access.

I imported some text from a document to paste into an
Excel worksheet, and that went pretty well.

But, some of the columns are askew because the country
column is normally one word, but when a country has two
or three words, then the columns get screwed up. ie.
Canada is in one column, but United States gets put into
two columns.

So now, trying to clean up the columns, it is a real pain
to clean them up. I can't cut and paste the text from one
column into the other, so I thought the concantenate
function might work.

I thought a VBA solution where I highlighted to range of
cells that I want to concantenate, pressed a command
button and voila, the strings would be in one column.

Any other better ideas or thoughts on how to program this?

Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default simple excel VBA programming

Paul,

Here's some code to do it

Dim cCols As Long, j As Long
Dim cRows As Long, i As Long
Dim oStart As Range

Set oStart = Selection.Cells(1, 1)
On Error Resume Next
With Selection
cCols = .Columns.Count
cRows = .Rows.Count
For i = 1 To cRows
For j = 2 To cCols
oStart.Cells(i, 1) = oStart.Cells(i, 1) & " " &
oStart.Cells(i, j)
oStart.Cells(i, j) = ""
Next j
oStart.Cells(i, 1) = Trim(oStart.Cells(i, 1))
Next i
End With


You could do it with worksheet functions, but this is probably simpler.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul" wrote in message
...
I am fairly new to Excel and VBA, I have some VBA
background in Access.

I imported some text from a document to paste into an
Excel worksheet, and that went pretty well.

But, some of the columns are askew because the country
column is normally one word, but when a country has two
or three words, then the columns get screwed up. ie.
Canada is in one column, but United States gets put into
two columns.

So now, trying to clean up the columns, it is a real pain
to clean them up. I can't cut and paste the text from one
column into the other, so I thought the concantenate
function might work.

I thought a VBA solution where I highlighted to range of
cells that I want to concantenate, pressed a command
button and voila, the strings would be in one column.

Any other better ideas or thoughts on how to program this?

Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default simple excel VBA programming

Bob


Thanks for the help....I'll try this out later tonight...

Merry Christmas

Paul


-----Original Message-----
Paul,

Here's some code to do it

Dim cCols As Long, j As Long
Dim cRows As Long, i As Long
Dim oStart As Range

Set oStart = Selection.Cells(1, 1)
On Error Resume Next
With Selection
cCols = .Columns.Count
cRows = .Rows.Count
For i = 1 To cRows
For j = 2 To cCols
oStart.Cells(i, 1) = oStart.Cells(i, 1)

& " " &
oStart.Cells(i, j)
oStart.Cells(i, j) = ""
Next j
oStart.Cells(i, 1) = Trim(oStart.Cells(i, 1))
Next i
End With


You could do it with worksheet functions, but this is

probably simpler.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Paul" wrote in

message
...
I am fairly new to Excel and VBA, I have some VBA
background in Access.

I imported some text from a document to paste into an
Excel worksheet, and that went pretty well.

But, some of the columns are askew because the country
column is normally one word, but when a country has two
or three words, then the columns get screwed up. ie.
Canada is in one column, but United States gets put

into
two columns.

So now, trying to clean up the columns, it is a real

pain
to clean them up. I can't cut and paste the text from

one
column into the other, so I thought the concantenate
function might work.

I thought a VBA solution where I highlighted to range

of
cells that I want to concantenate, pressed a command
button and voila, the strings would be in one column.

Any other better ideas or thoughts on how to program

this?

Paul



.

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
Programming a simple formula anagaraj1 New Users to Excel 1 August 4th 05 03:32 PM
Simple Simple Excel usage question BookerW Excel Discussion (Misc queries) 1 June 23rd 05 10:06 PM
Excel Programming Dan Gorman Excel Programming 3 December 3rd 03 11:34 PM
Excel Programming Aravind[_2_] Excel Programming 0 September 10th 03 08:05 AM
Help With Simple Combobox Programming MAB[_3_] Excel Programming 1 August 27th 03 04:23 PM


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