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

Hi,

I am a newbie in VB and I was trying to code a funtion in it where it
concatinates all the elements in a row in 'sheetx' and make it into one
string and paste it into a row of 'sheety'.
Thus my code reads...

Sub Convert_Map_to_Text()

Dim sMap As String

For i = 5 To 24
For j = 2 To 80

sMap = sMap + Worksheets("Sheet3").Cells(i, j)
Next j

Worksheets("Sheet4").cell(i - 4, 1) = sMap
Next i


End Sub
--------------------

But I got the following error.

type run error 13
type Mismatch

Can some one point out why this is happening, and if possible a
solution for the same?

Thank you very much in advance.

Regards,
Praveen.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Concatinating cells

Hi Praveen,

The following worked for me

Sub Convert_Map_to_Text()

Dim sMap As String
Dim i As Long, j As Long

For i = 5 To 24
For j = 2 To 80

sMap = sMap + _
CStr(ActiveSheet.Cells(i, j).Value)
Next j
Worksheets("Sheet4").Cells(i, 1).Value = sMap
Next i

End Sub

---
Regards,
Norman



"Praveen" wrote in message
oups.com...
Hi,

I am a newbie in VB and I was trying to code a funtion in it where it
concatinates all the elements in a row in 'sheetx' and make it into one
string and paste it into a row of 'sheety'.
Thus my code reads...

Sub Convert_Map_to_Text()

Dim sMap As String

For i = 5 To 24
For j = 2 To 80

sMap = sMap + Worksheets("Sheet3").Cells(i, j)
Next j

Worksheets("Sheet4").cell(i - 4, 1) = sMap
Next i


End Sub
--------------------

But I got the following error.

type run error 13
type Mismatch

Can some one point out why this is happening, and if possible a
solution for the same?

Thank you very much in advance.

Regards,
Praveen.



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

Hi,
You have certainly removed the error. But since the Smap vaiable is not
getting cleared it will carying the whole string from the previous row
also.. I have to just look into that also...

Any way thanks a lot for the break through !!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Concatinating cells

Hi Praveen,

Sub Convert_Map_to_Text2()

Dim sMap As String
Dim i As Long, j As Long

For i = 5 To 24
For j = 2 To 80

sMap = sMap + _
CStr(ActiveSheet.Cells(i, j).Value)
Next j
Worksheets("Sheet4").Cells(i, 1).Value = sMap
sMap = "" '<<==============
Next i

End Sub


---
Regards,
Norman



"Praveen" wrote in message
ups.com...
Hi,
You have certainly removed the error. But since the Smap vaiable is not
getting cleared it will carying the whole string from the previous row
also.. I have to just look into that also...

Any way thanks a lot for the break through !!!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Concatinating cells

THANKS Alot ... just now I did that. I got the same idea struck in my
head also. Thanks again...

Regards,
Praveen.



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
Excel: match two cells in one sheet to two cells in another and return a third cells value Spence Excel Worksheet Functions 3 February 13th 11 05:33 AM
compare 2 column cells and return the adjacent columns cells data of the cell trebor57 Excel Worksheet Functions 1 February 1st 11 02:54 PM
Concatinating text plus cell containing date Lori Excel Worksheet Functions 2 October 17th 07 08:06 PM
Concatinating a string of numbers - how? drod Excel Discussion (Misc queries) 5 August 2nd 06 10:02 PM
Skip cells with TAB/SHIFT+TAB but allow arrow keys/mouse selection of skipped cells Wescotte Excel Programming 1 June 6th 05 07:00 PM


All times are GMT +1. The time now is 03:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"