Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Adding text to cells

I have a spreadsheet with 732 entries in column A. I want to create a macro
that will add a "\\" to the beginning of each entry. I also want it done
only for non-blank cells. How can I do this? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Adding text to cells

Try something like

Dim Rng As Range
For Each Rng In ActiveSheet.UsedRange.Columns(1). _
SpecialCells(xlCellTypeConstants).Cells
Rng.Value = "\\" & Rng.Text
Next Rng



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"MAWII" wrote in message
...
I have a spreadsheet with 732 entries in column A. I want to
create a macro
that will add a "\\" to the beginning of each entry. I also
want it done
only for non-blank cells. How can I do this? Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 167
Default Adding text to cells

Sub MyMacro()
Dim i
i = Sheet1.Cells(65536, 1).End(xlUp).Row
For j = 1 To i
If Not Sheet1.Cells(j, 1).Value = "" Then
Sheet1.Cells(j, 1).Value = "\\" & Sheet1.Cells(j, 1).Value
End If
Next
End Sub

"MAWII" wrote:

I have a spreadsheet with 732 entries in column A. I want to create a macro
that will add a "\\" to the beginning of each entry. I also want it done
only for non-blank cells. How can I do this? Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Adding text to cells

I managed to pull it off with this (shortly after posting this message the
lightbulb went off):

Dim mycell As Range

For Each mycell In Range("A:A").Cells
If mycell.Value < "" Then
mycell.Value = "\\" & mycell.Value & "\c$"
End If
Next

How can I go through the cells and if there's already a "\\" at the
beginning of the cell entry, it won't add the "\\"?

Thanks!

"Chip Pearson" wrote:

Try something like

Dim Rng As Range
For Each Rng In ActiveSheet.UsedRange.Columns(1). _
SpecialCells(xlCellTypeConstants).Cells
Rng.Value = "\\" & Rng.Text
Next Rng



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"MAWII" wrote in message
...
I have a spreadsheet with 732 entries in column A. I want to
create a macro
that will add a "\\" to the beginning of each entry. I also
want it done
only for non-blank cells. How can I do 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
Adding text in cells Skip cell with dates[_2_] New Users to Excel 1 August 25th 08 02:36 PM
Adding Cells that Contain Text [email protected] Excel Worksheet Functions 6 October 12th 07 11:21 PM
Adding Cells that Contain Text [email protected] Excel Discussion (Misc queries) 2 October 12th 07 06:54 PM
Adding a lot of text to MS Excel cells macaleer16 Excel Discussion (Misc queries) 2 March 25th 05 02:31 PM
Adding two text cells together Audrey Excel Discussion (Misc queries) 4 February 24th 05 09:57 PM


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