Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 183
Default concatenate cell.value

I am trying to concatenate 2 values (for instance new value in cell D4=
current value cell D4 + value Cell D3)

I get an error message 13 with this code:
For Each cell In Columns(4)
cell.Value = cell.Value & cell.Offset(0, -1).Value
Next

Any idea?
thanks
--
caroline
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default concatenate cell.value

You had Value which is a number and excel doesn't like AND (&) a number.

cell.Value = cell.Text & cell.Offset(0, -1).Text

"caroline" wrote:

I am trying to concatenate 2 values (for instance new value in cell D4=
current value cell D4 + value Cell D3)

I get an error message 13 with this code:
For Each cell In Columns(4)
cell.Value = cell.Value & cell.Offset(0, -1).Value
Next

Any idea?
thanks
--
caroline

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default concatenate cell.value

Try something like:

Sub caroline()
For Each cell In Range("D1:D100")
cell.Value = cell.Value & cell.Offset(0, -1).Value
Next
End Sub
--
Gary''s Student - gsnu200810


"caroline" wrote:

I am trying to concatenate 2 values (for instance new value in cell D4=
current value cell D4 + value Cell D3)

I get an error message 13 with this code:
For Each cell In Columns(4)
cell.Value = cell.Value & cell.Offset(0, -1).Value
Next

Any idea?
thanks
--
caroline

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default concatenate cell.value

You are trying to concantanate using the value that you are replacing in the
same cell.

2 options

1

use a different cell to concantanate the 2 values

Sub tst()

For Each cell In Columns(5)
cell.FormulaR1C1 = "=rc[-2] & rc[-1]"
Next

End Sub

or

assign the value that is in column d to a variable and concantante col c
with the variable

HTH

"caroline" wrote:

I am trying to concatenate 2 values (for instance new value in cell D4=
current value cell D4 + value Cell D3)

I get an error message 13 with this code:
For Each cell In Columns(4)
cell.Value = cell.Value & cell.Offset(0, -1).Value
Next

Any idea?
thanks
--
caroline

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default concatenate cell.value

For starters..........Offset(0, -1) is C4, not D3

If you meant D3 then Offset(-1, 0)

Bur that will keep adding the contents from each cell in column D to the
next cell below to the next cell below to the next cell below...............

Gonna get a lot of content by the time you loop through column D

If you meant C4 then try this to loop through the used range in column D

Dim rng1 As Range
Range("D1").Select
Set rng1 = Range(ActiveCell, Cells(Rows.Count, _
ActiveCell.Column).End(xlUp))
For Each cell In rng1
cell.Value = cell.Value & cell.Offset(0, -1).Value
Next


Gord Dibben MS Excel MVP

On Mon, 27 Oct 2008 11:53:03 -0700, caroline
wrote:

I am trying to concatenate 2 values (for instance new value in cell D4=
current value cell D4 + value Cell D3)

I get an error message 13 with this code:
For Each cell In Columns(4)
cell.Value = cell.Value & cell.Offset(0, -1).Value
Next

Any idea?
thanks




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default concatenate cell.value

If you meant D3 then Offset(-1, 0)

But you could not use this on an entire column

D1 has no Offset(-1, 0)

So a range would be required like D2:D1000


Gord


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
Concatenate text cell and formula cell result GoinCrazy Excel Worksheet Functions 4 November 26th 08 04:27 PM
Concatenate list of cell values into one cell bony_tony Excel Programming 3 June 19th 07 06:05 PM
How to concatenate a value in cell ub Excel Worksheet Functions 4 May 29th 07 05:32 PM
concatenate from one cell to another David Vollmer[_2_] Excel Programming 2 March 10th 06 08:49 PM
concatenate cell valmont Excel Worksheet Functions 2 March 11th 05 03:25 PM


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