Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Eliminate blank row at top of Text Box entries

This code works just fine, (notice Claus in the sub name, thank you).
It does produce a blank row at the top of any entries in the text box.
To me, that is just fine, in fact I prefer that over no top margin.

However, the end user wants it gone.
I've tried some variations of this line along with a parse of the text box properties and cannot find a way to just eliminate the blank row. I was able to eliminate it with one revamp of the code line but it then produced double entries of each entry.

I need to keep the current entries already in the box and add to them with additional entries, which this line just below here does. But with an empty box the first entry needs to go to the very top of the box.

Regards,
Howard


ActiveSheet.TextBox1.Text = ActiveSheet.TextBox1.Text _
& vbCr & MyStringVariable


Option Explicit

Sub TheT_Box_Claus()
Dim MyStringVariable As String '
Dim IndexCol As Range '
Dim IndexLibry As Range '
Dim c As Range '
Dim rngC As Range '
Dim strIn As String '
Dim varOut As Variant '
Dim myCount As Integer '

Set IndexCol = Sheets("Input").Range("A2:A100")
Set IndexLibry = Sheets("Sort").Range("A3:A25")

strIn = Application.InputBox("Enter one number or " _
& "more numbers comma delimited", Type:=3)
myCount = Len(strIn) - _
Len(WorksheetFunction.Substitute(strIn, ",", ""))
IndexLibry.ClearContents

If myCount = 0 Then
[A3] = strIn
Else
varOut = Split(strIn, ",")
Cells(3, 1).Resize(myCount + 1, 1) = _
WorksheetFunction.Transpose(varOut)
End If

For Each c In IndexLibry
Set rngC = IndexCol.Find(c, LookIn:=xlValues, lookat:=xlWhole)
If Not rngC Is Nothing And rngC < "" Then

'*****/// add additional columns here ///******
' Lets just call this an add-column unit: & ", " & rngC.Offset(0, 10)
' the "&" appends the code to existing code.
' the ", " adds a comma between the column entries.
' then you need another "&"
' and this defines the column you want to add: rngC.Offset(0, 10)
' so the add-column shown above would add column K, _
' 10 columns to the right of the IndexCol
' the one with the header "G(#F,#R)"
' and you would insert it in the code to suit the order of _
' apperance you want in the text box

MyStringVariable = "(" & rngC & ") " & rngC.Offset(0, 4) _
& ", " & rngC.Offset(0, 1) & ", " & rngC.Offset(0, 2) _
& ", " & rngC.Offset(0, 14) & ", " & rngC.Offset(0, 15) _
& ", " & rngC.Offset(0, 18)
ActiveSheet.TextBox1.Text = ActiveSheet.TextBox1.Text _
& vbCr & MyStringVariable
End If
Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Eliminate blank row at top of Text Box entries

This code works just fine, (notice Claus in the sub name, thank you).
It does produce a blank row at the top of any entries in the text
box. To me, that is just fine, in fact I prefer that over no top
margin.

However, the end user wants it gone.
I've tried some variations of this line along with a parse of the
text box properties and cannot find a way to just eliminate the blank
row. I was able to eliminate it with one revamp of the code line but
it then produced double entries of each entry.

I need to keep the current entries already in the box and add to them
with additional entries, which this line just below here does. But
with an empty box the first entry needs to go to the very top of the
box.

Regards,
Howard


ActiveSheet.TextBox1.Text = ActiveSheet.TextBox1.Text _
& vbCr & MyStringVariable


Option Explicit

Sub TheT_Box_Claus()
Dim MyStringVariable As String '
Dim IndexCol As Range '
Dim IndexLibry As Range '
Dim c As Range '
Dim rngC As Range '
Dim strIn As String '
Dim varOut As Variant '
Dim myCount As Integer '

Set IndexCol = Sheets("Input").Range("A2:A100")
Set IndexLibry = Sheets("Sort").Range("A3:A25")

strIn = Application.InputBox("Enter one number or " _
& "more numbers comma delimited", Type:=3)
myCount = Len(strIn) - _
Len(WorksheetFunction.Substitute(strIn, ",", ""))
IndexLibry.ClearContents

If myCount = 0 Then
[A3] = strIn
Else
varOut = Split(strIn, ",")
Cells(3, 1).Resize(myCount + 1, 1) = _
WorksheetFunction.Transpose(varOut)
End If

For Each c In IndexLibry
Set rngC = IndexCol.Find(c, LookIn:=xlValues, lookat:=xlWhole)
If Not rngC Is Nothing And rngC < "" Then

'*****/// add additional columns here ///******
' Lets just call this an add-column unit: & ", " & rngC.Offset(0,
10) ' the "&" appends the code to existing code.
' the ", " adds a comma between the column entries.
' then you need another "&"
' and this defines the column you want to add: rngC.Offset(0, 10)
' so the add-column shown above would add column K, _
' 10 columns to the right of the IndexCol
' the one with the header "G(#F,#R)"
' and you would insert it in the code to suit the order of _
' apperance you want in the text box

MyStringVariable = "(" & rngC & ") " & rngC.Offset(0, 4) _
& ", " & rngC.Offset(0, 1) & ", " & rngC.Offset(0, 2) _
& ", " & rngC.Offset(0, 14) & ", " & rngC.Offset(0, 15) _
& ", " & rngC.Offset(0, 18)
ActiveSheet.TextBox1.Text = ActiveSheet.TextBox1.Text _
& vbCr & MyStringVariable
End If
Next

End Sub


What this tells me is that if the textbox is empty then it gets a vbCr
before the 1st line. Otherwise, if text exists then each new block of
text is separated from existing text by a vbCr. You can eliminate a
blank 1st row by...

With ActiveSheet.TextBox1
If Len(.Text) 0 Then MyStringVariable = vbCr & MyStringVariable
.Text = .Text & MyStringVariable
End With

...where you prepend the vbCr to MyStringVariable only when there's
existing text so the 1st block of text starts at the top when the
textbox is empty.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default Eliminate blank row at top of Text Box entries


What this tells me is that if the textbox is empty then it gets a vbCr

before the 1st line. Otherwise, if text exists then each new block of

text is separated from existing text by a vbCr. You can eliminate a

blank 1st row by...



With ActiveSheet.TextBox1

If Len(.Text) 0 Then MyStringVariable = vbCr & MyStringVariable

.Text = .Text & MyStringVariable

End With



..where you prepend the vbCr to MyStringVariable only when there's

existing text so the 1st block of text starts at the top when the

textbox is empty.



--

Garry



CAUTION: Genius at work!

Thanks, Garry. Your analysis was correct and the solution is perfect.

Of course I will keep the code that produces the blank row also.
So someone can have it either way.

Regards,
Howard


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Eliminate blank row at top of Text Box entries

What this tells me is that if the textbox is empty then it gets a
vbCr

before the 1st line. Otherwise, if text exists then each new block
of

text is separated from existing text by a vbCr. You can eliminate a

blank 1st row by...



With ActiveSheet.TextBox1

If Len(.Text) 0 Then MyStringVariable = vbCr & MyStringVariable

.Text = .Text & MyStringVariable

End With



..where you prepend the vbCr to MyStringVariable only when there's

existing text so the 1st block of text starts at the top when the

textbox is empty.



--

Garry



CAUTION: Genius at work!

Thanks, Garry. Your analysis was correct and the solution is
perfect.

Of course I will keep the code that produces the blank row also.
So someone can have it either way.

Regards,
Howard


You're welcome! I appreciate the feedback...

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
Eliminate double entries in datalist in bulk [email protected] Excel Discussion (Misc queries) 0 October 17th 07 03:15 PM
Eliminate Overlapping Entries Mark@Marc Excel Worksheet Functions 4 February 20th 06 10:51 PM
In 2 Excel worksheets, I am trying to eliminate duplicate entries jgentile Excel Worksheet Functions 2 November 6th 05 01:05 AM
How to eliminate duplicate entries Tara Keane Excel Discussion (Misc queries) 4 March 2nd 05 05:33 PM
eliminate duplicate entries in column automatically Frank Kabel Excel Programming 0 September 10th 04 04:36 PM


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