Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Hopefully a simple macro to precatenate data in a column

Sorry if this is really easy or not possible. I'm a dba with very little
Excel experience. I've been given an Excel spreadsheet to import into a
relational database there are some data consistency issues...

Anyway, what I'd like to do is insert an underscore at the front of the data
in each cell in a column - preferably in only those cells that have data. So
if the cell has ABCDEF in it it'd become _ABCDEF .

Any clues on how to accomplish this? Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Hopefully a simple macro to precatenate data in a column

Use a helper column:

Say your data is in column A. In B1 enter:

="_" & A1
and copy down. Then copy column B and paste/special/values back onto column
A.
--
Gary''s Student - gsnu200781


"Jon in Canby Or." wrote:

Sorry if this is really easy or not possible. I'm a dba with very little
Excel experience. I've been given an Excel spreadsheet to import into a
relational database there are some data consistency issues...

Anyway, what I'd like to do is insert an underscore at the front of the data
in each cell in a column - preferably in only those cells that have data. So
if the cell has ABCDEF in it it'd become _ABCDEF .

Any clues on how to accomplish this? Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Hopefully a simple macro to precatenate data in a column

That's helpful but I was hoping for something more automated. I should've
written that I have a lot of worksheets and a lot of columns to do this on.
This solution would still be fairly labor intensive and prone to errors or my
part.

Does anybody have a more automated method?

Cheers

"Gary''s Student" wrote:

Use a helper column:

Say your data is in column A. In B1 enter:

="_" & A1
and copy down. Then copy column B and paste/special/values back onto column
A.
--
Gary''s Student - gsnu200781


"Jon in Canby Or." wrote:

Sorry if this is really easy or not possible. I'm a dba with very little
Excel experience. I've been given an Excel spreadsheet to import into a
relational database there are some data consistency issues...

Anyway, what I'd like to do is insert an underscore at the front of the data
in each cell in a column - preferably in only those cells that have data. So
if the cell has ABCDEF in it it'd become _ABCDEF .

Any clues on how to accomplish this? Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default Hopefully a simple macro to precatenate data in a column

Create a helper column to the right of your data column, and use the
following formula to add the underscore "_" as a prefix character (Modifying
the A1 cell address to match your worksheet layout):

=IF(ISBLANK(A1),"","_"&A1)

Copy down to the last data row then copy the entire formula column, click on
the first cell of the original data column (Cell A1 in the formula example),
then click EDIT in the menu, select PASTE SPECIAL and click the VALUES option
button. Click OK to complete the process and exit the dialog box. Delete
the helper column when done.
--
Kevin Backmann


"Jon in Canby Or." wrote:

Sorry if this is really easy or not possible. I'm a dba with very little
Excel experience. I've been given an Excel spreadsheet to import into a
relational database there are some data consistency issues...

Anyway, what I'd like to do is insert an underscore at the front of the data
in each cell in a column - preferably in only those cells that have data. So
if the cell has ABCDEF in it it'd become _ABCDEF .

Any clues on how to accomplish this? Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Hopefully a simple macro to precatenate data in a column

That's better for taking care of the blank columns but you must've missed my
reply to the last suggestion as they were both posted within minutes of
eachother.

"Kevin B" wrote:

Create a helper column to the right of your data column, and use the
following formula to add the underscore "_" as a prefix character (Modifying
the A1 cell address to match your worksheet layout):

=IF(ISBLANK(A1),"","_"&A1)

Copy down to the last data row then copy the entire formula column, click on
the first cell of the original data column (Cell A1 in the formula example),
then click EDIT in the menu, select PASTE SPECIAL and click the VALUES option
button. Click OK to complete the process and exit the dialog box. Delete
the helper column when done.
--
Kevin Backmann


"Jon in Canby Or." wrote:

Sorry if this is really easy or not possible. I'm a dba with very little
Excel experience. I've been given an Excel spreadsheet to import into a
relational database there are some data consistency issues...

Anyway, what I'd like to do is insert an underscore at the front of the data
in each cell in a column - preferably in only those cells that have data. So
if the cell has ABCDEF in it it'd become _ABCDEF .

Any clues on how to accomplish this? Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Hopefully a simple macro to precatenate data in a column

I would go with =IF(A1="","","_" & A1)

OP wanted to add the underscore just if A had a value.


Gord Dibben MS Excel MVP

On Tue, 29 Apr 2008 11:16:05 -0700, Gary''s Student
wrote:

Use a helper column:

Say your data is in column A. In B1 enter:

="_" & A1
and copy down. Then copy column B and paste/special/values back onto column
A.


  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Hopefully a simple macro to precatenate data in a column

Select a column and run this macro:

Sub JonInCanby()
For Each r In Selection
v = r.Value
If IsEmpty(v) Then
Else
r.Value = "_" & v
End If
Next
End Sub

It will apply the prefix in one swell foop!
--
Gary''s Student - gsnu200782


"Jon in Canby Or." wrote:

That's helpful but I was hoping for something more automated. I should've
written that I have a lot of worksheets and a lot of columns to do this on.
This solution would still be fairly labor intensive and prone to errors or my
part.

Does anybody have a more automated method?

Cheers

"Gary''s Student" wrote:

Use a helper column:

Say your data is in column A. In B1 enter:

="_" & A1
and copy down. Then copy column B and paste/special/values back onto column
A.
--
Gary''s Student - gsnu200781


"Jon in Canby Or." wrote:

Sorry if this is really easy or not possible. I'm a dba with very little
Excel experience. I've been given an Excel spreadsheet to import into a
relational database there are some data consistency issues...

Anyway, what I'd like to do is insert an underscore at the front of the data
in each cell in a column - preferably in only those cells that have data. So
if the cell has ABCDEF in it it'd become _ABCDEF .

Any clues on how to accomplish this? Thanks.

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Hopefully a simple macro to precatenate data in a column

Perfect! That's exactly what I was looking for. Thanks for the help.

"Gary''s Student" wrote:

Select a column and run this macro:

Sub JonInCanby()
For Each r In Selection
v = r.Value
If IsEmpty(v) Then
Else
r.Value = "_" & v
End If
Next
End Sub

It will apply the prefix in one swell foop!
--
Gary''s Student - gsnu200782


"Jon in Canby Or." wrote:

That's helpful but I was hoping for something more automated. I should've
written that I have a lot of worksheets and a lot of columns to do this on.
This solution would still be fairly labor intensive and prone to errors or my
part.

Does anybody have a more automated method?

Cheers

"Gary''s Student" wrote:

Use a helper column:

Say your data is in column A. In B1 enter:

="_" & A1
and copy down. Then copy column B and paste/special/values back onto column
A.
--
Gary''s Student - gsnu200781


"Jon in Canby Or." wrote:

Sorry if this is really easy or not possible. I'm a dba with very little
Excel experience. I've been given an Excel spreadsheet to import into a
relational database there are some data consistency issues...

Anyway, what I'd like to do is insert an underscore at the front of the data
in each cell in a column - preferably in only those cells that have data. So
if the cell has ABCDEF in it it'd become _ABCDEF .

Any clues on how to accomplish this? Thanks.

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
macro to move to minimum value in column of data g_noggle Excel Discussion (Misc queries) 2 November 8th 07 02:32 PM
I need an Excel macro which will de-dupe a column of data? JPAuctions Excel Discussion (Misc queries) 1 July 18th 06 04:44 PM
Macro to find the first cell in a column with different data Lost in Alabama Excel Discussion (Misc queries) 2 December 14th 05 06:39 PM
Need to add data to the bottom of a column using macro Rick Excel Discussion (Misc queries) 0 September 7th 05 01:14 AM
Macro to move data to different column based on data in another co malycom Excel Discussion (Misc queries) 3 August 2nd 05 07:07 PM


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