Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding a "1" in front of everything in column A


I'd like to add a "1" (number one) in front of everything in column A.
can use =1&A1 but it's too tedius to do to every record in ever
spreadsheet.

I tried creating a macro, but for blank rows say A1 to A100 hav
numbers, but after that it adds a 1 in an empty cell.

Is there anyone who can help me with this

--
alexm99
-----------------------------------------------------------------------
alexm999's Profile: http://www.excelforum.com/member.php...nfo&userid=491
View this thread: http://www.excelforum.com/showthread.php?threadid=49031

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Adding a "1" in front of everything in column A

try this, i am assuming the string you want is text so it didn't sum if
there were existing numbers:

Option Explicit
Dim lastrow As Long
Dim cell As Range
Sub test()
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("A1:A" & lastrow)
cell.Value = "1" & cell.Value
Next

End Sub

--


Gary


"alexm999" wrote in
message ...

I'd like to add a "1" (number one) in front of everything in column A. I
can use =1&A1 but it's too tedius to do to every record in every
spreadsheet.

I tried creating a macro, but for blank rows say A1 to A100 have
numbers, but after that it adds a 1 in an empty cell.

Is there anyone who can help me with this?


--
alexm999
------------------------------------------------------------------------
alexm999's Profile:
http://www.excelforum.com/member.php...fo&userid=4918
View this thread: http://www.excelforum.com/showthread...hreadid=490316



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,073
Default Adding a "1" in front of everything in column A

Hi Alex,
If you don't want to use a macro you could try filling this formula
down a spare column starting in row 2 (You probably have a heading in
row 1)

=IF(A2<"","1" & A2,"")

This avoids the problem you are having with blank cells.

Ken Johnson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Adding a "1" in front of everything in column A


Or,

Sub AddOne()

For each c in Range("a:a")
If Not Isempty(c) Then
c.value = 1 & c.value
End if
Next

End Sub


--
Myles
------------------------------------------------------------------------
Myles's Profile: http://www.excelforum.com/member.php...o&userid=28746
View this thread: http://www.excelforum.com/showthread...hreadid=490316

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
Adding data only if adjacent to cell labeled "male"/"female" lovesrubbaducky Excel Worksheet Functions 1 November 23rd 09 05:49 PM
Adding "letters (column headings)" Rachael Excel Discussion (Misc queries) 7 June 13th 06 05:07 PM
LOOP BETWEEN "FRONT" AND "END" SHEETS? ewan7279 Excel Programming 7 March 17th 05 03:11 PM
Adding "TOTAL" and summing column Fred Butterfield Excel Programming 3 May 18th 04 02:20 AM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


All times are GMT +1. The time now is 02:57 AM.

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"