Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to add data

I have a column in a table to which I would like to add
the same data to every record in the column. Following
is an example: Each record in my column B of the
spreadsheet contains a unique value. I would like to
preface that unique value, in every record in column B
with the same path name. So if B2 currently
contains "1233" in the field. I would like the macro to
add "c:\data\" in front of it so the final result of the
field is "c:\data\1233


TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Macro to add data

Hi Janna,

Assuming that your table has a header row, try:

Sub Tester()
Dim rng As Range, cell As Range
Dim Lstcell As Range

Set Lstcell = Cells(Rows.Count, "B").End(xlUp)

Set rng = Range(Lstcell, Lstcell.End(xlUp)(2))

For Each cell In rng
cell.Value = "c:\data\" & cell.Value
Next

End Sub


---
Regards,
Norman



"Janna" wrote in message
...
I have a column in a table to which I would like to add
the same data to every record in the column. Following
is an example: Each record in my column B of the
spreadsheet contains a unique value. I would like to
preface that unique value, in every record in column B
with the same path name. So if B2 currently
contains "1233" in the field. I would like the macro to
add "c:\data\" in front of it so the final result of the
field is "c:\data\1233


TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro to add data

Thanks Norman

It worked like a charm :-)

Janna

-----Original Message-----
Hi Janna,

Assuming that your table has a header row, try:

Sub Tester()
Dim rng As Range, cell As Range
Dim Lstcell As Range

Set Lstcell = Cells(Rows.Count, "B").End(xlUp)

Set rng = Range(Lstcell, Lstcell.End(xlUp)(2))

For Each cell In rng
cell.Value = "c:\data\" & cell.Value
Next

End Sub


---
Regards,
Norman



"Janna" wrote in

message
...
I have a column in a table to which I would like to add
the same data to every record in the column. Following
is an example: Each record in my column B of the
spreadsheet contains a unique value. I would like to
preface that unique value, in every record in column B
with the same path name. So if B2 currently
contains "1233" in the field. I would like the macro

to
add "c:\data\" in front of it so the final result of

the
field is "c:\data\1233


TIA



.

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 copy data when data is detected in another column(s). Richard Excel Worksheet Functions 2 October 23rd 09 11:46 PM
Write Macro to Fix Data Alignment (Data dump from Crystal to Excel Karin Excel Discussion (Misc queries) 2 September 22nd 09 05:31 PM
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
enter data in cell which will start macro to move data to sheet2 Tommy Excel Discussion (Misc queries) 0 May 12th 05 05:00 PM
Macro that will autofill a column with data, up to the last row of data in previous c Max Velocity Excel Programming 4 November 27th 03 10:34 AM


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