Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Border around Data Entered in Variable Rows

Hello everyone-

I apologize for posting this problem twice (I posted it over in
excel.misc as well), but this seemed a more appropriate place to ask
this question.

I have a UserForm that, when filled out, places the data entered at
the end of a database. I would like to format the row to include a
border around the data (i.e., "box" it) so that it matches the other
sections in the database. I have 6 fields that are entered into the
row. My problem comes in defining the range to select to border.
Since the row where it inserts the data is variable, but the columns
remain the same (A:F), my range must also be variable. How do I tell
Excel to place a border around the entered data each time AND insert a
row between the new data and the bottom of the border? This is the
macro I have so far (yes, I had help with this one too):

Private Sub CommandButton1_Click()

Dim lngRow As Long
lngRow = Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row + 3
Cells(lngRow, 1).Value = TextBox1.Value

Cells(lngRow, 1).Select
Cells (lngRow, 1).Offset(0, 1).Value = TextBox2.Value
Cells (lngRow, 1).Offset(0, 2).Value = TextBox3.Value
Cells (lngRow, 1).Offset(0, 3).Value = TextBox4.Value
Cells (lngRow, 1).Offset(0, 4).Value = TextBox5.Value
Cells (lngRow, 1).Offset(0, 5).Value = TextBox6.Value
Cells (lngRow, 1).Offset(0, 6).Value = TextBox7.Value

Unload UserForm1

End Sub

Thanks for any help offered...

-Ray
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Border around Data Entered in Variable Rows

Private Sub CommandButton1_Click()

Dim lngRow As Long
lngRow = Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row + 3
Cells(lngRow, 1).Value = TextBox1.Value

Cells(lngRow, 1).Select
Cells (lngRow, 1).Offset(0, 1).Value = TextBox2.Value
Cells (lngRow, 1).Offset(0, 2).Value = TextBox3.Value
Cells (lngRow, 1).Offset(0, 3).Value = TextBox4.Value
Cells (lngRow, 1).Offset(0, 4).Value = TextBox5.Value
Cells (lngRow, 1).Offset(0, 5).Value = TextBox6.Value
Cells (lngRow, 1).Offset(0, 6).Value = TextBox7.Value
selection.Resize(2,6).BorderAround Weight:=xlMedium,
ColorIndex:=xlAutomatic

Unload UserForm1

End Sub

--
Regards,
Tom Ogilvy


"RGeneral" wrote in message
om...
Hello everyone-

I apologize for posting this problem twice (I posted it over in
excel.misc as well), but this seemed a more appropriate place to ask
this question.

I have a UserForm that, when filled out, places the data entered at
the end of a database. I would like to format the row to include a
border around the data (i.e., "box" it) so that it matches the other
sections in the database. I have 6 fields that are entered into the
row. My problem comes in defining the range to select to border.
Since the row where it inserts the data is variable, but the columns
remain the same (A:F), my range must also be variable. How do I tell
Excel to place a border around the entered data each time AND insert a
row between the new data and the bottom of the border? This is the
macro I have so far (yes, I had help with this one too):

Private Sub CommandButton1_Click()

Dim lngRow As Long
lngRow = Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row + 3
Cells(lngRow, 1).Value = TextBox1.Value

Cells(lngRow, 1).Select
Cells (lngRow, 1).Offset(0, 1).Value = TextBox2.Value
Cells (lngRow, 1).Offset(0, 2).Value = TextBox3.Value
Cells (lngRow, 1).Offset(0, 3).Value = TextBox4.Value
Cells (lngRow, 1).Offset(0, 4).Value = TextBox5.Value
Cells (lngRow, 1).Offset(0, 5).Value = TextBox6.Value
Cells (lngRow, 1).Offset(0, 6).Value = TextBox7.Value

Unload UserForm1

End Sub

Thanks for any help offered...

-Ray



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Border around Data Entered in Variable Rows

Thanks, Tom! So simple and it works like a charm!

-Ray


"Tom Ogilvy" wrote in message ...
Private Sub CommandButton1_Click()

Dim lngRow As Long
lngRow = Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row + 3
Cells(lngRow, 1).Value = TextBox1.Value

Cells(lngRow, 1).Select
Cells (lngRow, 1).Offset(0, 1).Value = TextBox2.Value
Cells (lngRow, 1).Offset(0, 2).Value = TextBox3.Value
Cells (lngRow, 1).Offset(0, 3).Value = TextBox4.Value
Cells (lngRow, 1).Offset(0, 4).Value = TextBox5.Value
Cells (lngRow, 1).Offset(0, 5).Value = TextBox6.Value
Cells (lngRow, 1).Offset(0, 6).Value = TextBox7.Value
selection.Resize(2,6).BorderAround Weight:=xlMedium,
ColorIndex:=xlAutomatic

Unload UserForm1

End Sub

--
Regards,
Tom Ogilvy


"RGeneral" wrote in message
om...
Hello everyone-

I apologize for posting this problem twice (I posted it over in
excel.misc as well), but this seemed a more appropriate place to ask
this question.

I have a UserForm that, when filled out, places the data entered at
the end of a database. I would like to format the row to include a
border around the data (i.e., "box" it) so that it matches the other
sections in the database. I have 6 fields that are entered into the
row. My problem comes in defining the range to select to border.
Since the row where it inserts the data is variable, but the columns
remain the same (A:F), my range must also be variable. How do I tell
Excel to place a border around the entered data each time AND insert a
row between the new data and the bottom of the border? This is the
macro I have so far (yes, I had help with this one too):

Private Sub CommandButton1_Click()

Dim lngRow As Long
lngRow = Worksheets(1).Cells(Rows.Count, "A").End(xlUp).Row + 3
Cells(lngRow, 1).Value = TextBox1.Value

Cells(lngRow, 1).Select
Cells (lngRow, 1).Offset(0, 1).Value = TextBox2.Value
Cells (lngRow, 1).Offset(0, 2).Value = TextBox3.Value
Cells (lngRow, 1).Offset(0, 3).Value = TextBox4.Value
Cells (lngRow, 1).Offset(0, 4).Value = TextBox5.Value
Cells (lngRow, 1).Offset(0, 5).Value = TextBox6.Value
Cells (lngRow, 1).Offset(0, 6).Value = TextBox7.Value

Unload UserForm1

End Sub

Thanks for any help offered...

-Ray

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 can I auto number rows only when data is entered in the same r Plateav Excel Discussion (Misc queries) 3 September 17th 09 11:24 PM
Adding rows once data is entered desperate in MS Excel Discussion (Misc queries) 1 February 9th 09 06:57 PM
Add rows when data is entered desperate in MS Excel Discussion (Misc queries) 0 February 9th 09 05:51 PM
Print only rows with data entered in an excel template hellaby Excel Discussion (Misc queries) 1 August 9th 08 04:16 PM
Border Formatting Disappearing when data entered into cell Orgelfreude Excel Discussion (Misc queries) 0 October 11th 05 01:51 AM


All times are GMT +1. The time now is 02:27 AM.

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"