Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default I want to put the text in the cell of column B in front of the the text in column D.

I want to put the text in the cell of column B in front of the the
text in column D.
But only if there is a text filled in in column D.

Does anybody have a VBA code for it?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default I want to put the text in the cell of column B in front of the thetext in column D.

I'd use a formula in a helper cell like:

=if(d1="","",b1&d1)
or
=if(d1="","",b1&" "&d1)

And drag down the column.

Then edit|copy that helper column
then select column D
and edit|paste special|values



bartman1980 wrote:

I want to put the text in the cell of column B in front of the the
text in column D.
But only if there is a text filled in in column D.

Does anybody have a VBA code for it?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default I want to put the text in the cell of column B in front of the the text in column D.

On 13 aug, 14:09, Dave Peterson wrote:
I'd use a formula in a helper cell like:

=if(d1="","",b1&d1)
or
=if(d1="","",b1&" "&d1)

And drag down the column.

Then edit|copy that helper column
then select column D
and edit|paste special|values

bartman1980 wrote:

I want to put the text in the cell of column B in front of the the
text in column D.
But only if there is a text filled in in column D.


Does anybody have a VBA code for it?


--

Dave Peterson


Hi Dave,
I can do this, but I want it in a VBA code.
I'm sure it can be made in a VBA code.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default I want to put the text in the cell of column B in front of the thetext in column D.

Option Explicit
Sub testme()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

With Worksheets("sheet1")
FirstRow = 2 'headers in row 1???
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row

For iRow = FirstRow To LastRow
If IsEmpty(.Cells(iRow, "D").Value) Then
'skip it
Else
.Cells(iRow, "D").Value _
= .Cells(iRow, "B").Text & " " & .Cells(iRow, "D").Text
End If
Next iRow
End With
End Sub

I put a space character between the values. Remove it or change it to what you
want.

bartman1980 wrote:

I want to put the text in the cell of column B in front of the the
text in column D.
But only if there is a text filled in in column D.

Does anybody have a VBA code for it?


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default I want to put the text in the cell of column B in front of the the text in column D.

On 13 aug, 14:22, Dave Peterson wrote:
Option Explicit
Sub testme()

Dim FirstRow As Long
Dim LastRow As Long
Dim iRow As Long

With Worksheets("sheet1")
FirstRow = 2 'headers in row 1???
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row

For iRow = FirstRow To LastRow
If IsEmpty(.Cells(iRow, "D").Value) Then
'skip it
Else
.Cells(iRow, "D").Value _
= .Cells(iRow, "B").Text & " " & .Cells(iRow, "D").Text
End If
Next iRow
End With
End Sub

I put a space character between the values. Remove it or change it to what you
want.

bartman1980 wrote:

I want to put the text in the cell of column B in front of the the
text in column D.
But only if there is a text filled in in column D.


Does anybody have a VBA code for it?


--

Dave Peterson


Thank you dave!
This works!

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
How to subtract one text column based on their text column MS xls. Salahuddin Excel Discussion (Misc queries) 4 October 27th 08 04:57 AM
Find a text from a column in a text string within another column? Mike Garcia[_2_] New Users to Excel 1 October 22nd 08 06:50 PM
HowTo add a period to front of EVERY text cell in a Excel column adamcollegeman Excel Programming 4 November 24th 05 07:51 AM
Wrap text in column headers to fit text in column MarkN Excel Discussion (Misc queries) 10 November 11th 05 04:21 AM
Deleting Rows based on text in cell & formatting cell based on text in column beside it Steve Excel Programming 4 February 26th 04 03:31 PM


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