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

Hello!
I´have a problem with merging several textcell together. In one kolumn i
have textcells and in another column numbers. I´d like excel to merge the
textcells together if the row have number zero. The merge text should also be
on different rows.
A B
1 Cars 1
2 Dogs 0
3 Cats 1
4 Candy 0
5 icecream 0

New cell in a diffrent worksheet:
Dogs
Candy
icecream

Can i copy this makro or formula in an easy way even if the cellreference is
different.

thank you so much for your help/ Johan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Merge cells if value is zero

So basically you want to delete the rows where column B is not 0?

--
Dan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Merge cells if value is zero

Yes, that is correct, that is a much simplier way of explaining it , haven´t
thought about it in that direction before.

/Johan



"Dan R." skrev:

So basically you want to delete the rows where column B is not 0?

--
Dan


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Merge cells if value is zero

Maybe you could select column B
Data|Filter|autofilter
show the rows where column B equals 0
delete those visible cells
(Or copy those visible cells to a new worksheet????)

You may just want to filter values that are not equal to 0.

The data will still be there--just in case you need it.

sandman007 wrote:

Yes, that is correct, that is a much simplier way of explaining it , haven´t
thought about it in that direction before.

/Johan

"Dan R." skrev:

So basically you want to delete the rows where column B is not 0?

--
Dan



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Merge cells if value is zero

Yes, that should work but i still like to merge the text to only one cell,
with new row for every textcell. Another problem, will this filter work if
you have several columns with numbers and every column should have there own
list with text.
A B C D E etc.
1 Cars 1 0 1
2 Dogs 0 1 1
3 Cats 1 0 0
4 Candy 0 0 1
5 icecream 0 0 0

New cell 1:
Dogs
Candy
Icecream

New cell 2:
Cars
Cats
Candy
Icecream

etc. etc.

/Johan

"Dave Peterson" skrev:

Maybe you could select column B
Data|Filter|autofilter
show the rows where column B equals 0
delete those visible cells
(Or copy those visible cells to a new worksheet????)

You may just want to filter values that are not equal to 0.

The data will still be there--just in case you need it.

sandman007 wrote:

Yes, that is correct, that is a much simplier way of explaining it , haven´t
thought about it in that direction before.

/Johan

"Dan R." skrev:

So basically you want to delete the rows where column B is not 0?

--
Dan



--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Merge cells if value is zero

This may work for you:

Option Explicit
Sub testme()
Dim CurWks As Worksheet
Dim RptWks As Worksheet
Dim iRow As Long
Dim iCol As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim FirstCol As Long
Dim LastCol As Long
Dim oRow As Long
Dim myStr As String

Set CurWks = Worksheets("Sheet1")
Set RptWks = Worksheets.Add

oRow = 0
With CurWks
FirstRow = 1 'no headers
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
FirstCol = 2 'items in column A
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column

For iCol = FirstCol To LastCol
myStr = ""
If Application.CountIf(.Range(.Cells(FirstRow, iCol), _
.Cells(LastRow, iCol)), 0) = 0 Then
'no zeros in that column, skip it
Else
oRow = oRow + 1
For iRow = FirstRow To LastRow
If .Cells(iRow, iCol).Value = 0 Then
'vblf is the same as alt-enter
myStr = myStr & .Cells(iRow, "A").Value & vbLf
End If
Next iRow
RptWks.Cells(oRow, "A").Value = Left(myStr, Len(myStr) - 1)
End If
Next iCol
End With

With RptWks.UsedRange
.WrapText = True
.Columns.AutoFit
End With

End Sub


sandman007 wrote:

Yes, that should work but i still like to merge the text to only one cell,
with new row for every textcell. Another problem, will this filter work if
you have several columns with numbers and every column should have there own
list with text.
A B C D E etc.
1 Cars 1 0 1
2 Dogs 0 1 1
3 Cats 1 0 0
4 Candy 0 0 1
5 icecream 0 0 0

New cell 1:
Dogs
Candy
Icecream

New cell 2:
Cars
Cats
Candy
Icecream

etc. etc.

/Johan

"Dave Peterson" skrev:

Maybe you could select column B
Data|Filter|autofilter
show the rows where column B equals 0
delete those visible cells
(Or copy those visible cells to a new worksheet????)

You may just want to filter values that are not equal to 0.

The data will still be there--just in case you need it.

sandman007 wrote:

Yes, that is correct, that is a much simplier way of explaining it , haven´t
thought about it in that direction before.

/Johan

"Dan R." skrev:

So basically you want to delete the rows where column B is not 0?

--
Dan



--

Dave Peterson


--

Dave Peterson
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
Automatically merge mulitiple cells to one cells Edward Wang Excel Worksheet Functions 5 September 15th 09 07:56 PM
how do I merge cells into one then delete the original cells? LLR Excel Worksheet Functions 2 March 7th 08 10:59 PM
How can I have formatting options like merge cells ,Bold,active for the unlocked cells of the protected worksheet.Is it possible in excel? divya Excel Programming 2 July 20th 06 02:04 PM
How do I merge cells in Excel, like just 2 cells to make one big . chattacat Excel Discussion (Misc queries) 2 January 19th 05 04:25 PM
fill cells, merge cells porkie[_3_] Excel Programming 0 September 22nd 04 06:50 AM


All times are GMT +1. The time now is 04:05 PM.

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"