Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Why does this not work?

TextBox1.Text = rng(1, "Start_1").Text

Start_1 is a range of cells ( AU3 :AU36) defined on the active worksheet. I
want the text from TextBox1 to be placed into the Start_1 of the current
row.

I want to use Defined Names, so that over time if I have to add or subtract
columns I will not have to go back and re-point all my references. The code
I used before was TextBox1.Text = rng(1, 47).Text (this is just one of
dozens of lines code), but if I added or removed columns the references all
had to be readjusted.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Why does this not work?

It kind of sounds like you want the first empty cell in that range to get the
value from your textbox.

If that's true, then you could do something like:

Option Explicit
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim myStart_1_Rng As Range

Set myStart_1_Rng = Worksheets("sheet1").Range("Start_1")

If Application.CountA(myStart_1_Rng) = myStart_1_Rng.Cells.Count Then
MsgBox "No empty cells in the range!"
Exit Sub
End If

For iRow = 1 To myStart_1_Rng.Rows.Count
If IsEmpty(myStart_1_Rng.Cells(iRow, 1)) Then
myStart_1_Rng.Cells(iRow, 1).Value = Me.TextBox1.Text
Exit For
End If
Next iRow

End Sub



Patrick Simonds wrote:

TextBox1.Text = rng(1, "Start_1").Text

Start_1 is a range of cells ( AU3 :AU36) defined on the active worksheet. I
want the text from TextBox1 to be placed into the Start_1 of the current
row.

I want to use Defined Names, so that over time if I have to add or subtract
columns I will not have to go back and re-point all my references. The code
I used before was TextBox1.Text = rng(1, 47).Text (this is just one of
dozens of lines code), but if I added or removed columns the references all
had to be readjusted.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Why does this not work?

No, what I want to have happen is, if I am on row 12 I want the text to go
into the Start_1 on row 12. In this example start_1 would be cell AU12.

The dialog box which contains the text for Start_1 is displayed when I click
on a cell in column A. This worked well when I was using TextBox1.Text =
rng(1, 47), but now I have to have the ability to add or remove columns.


"Dave Peterson" wrote in message
...
It kind of sounds like you want the first empty cell in that range to get
the
value from your textbox.

If that's true, then you could do something like:

Option Explicit
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim myStart_1_Rng As Range

Set myStart_1_Rng = Worksheets("sheet1").Range("Start_1")

If Application.CountA(myStart_1_Rng) = myStart_1_Rng.Cells.Count Then
MsgBox "No empty cells in the range!"
Exit Sub
End If

For iRow = 1 To myStart_1_Rng.Rows.Count
If IsEmpty(myStart_1_Rng.Cells(iRow, 1)) Then
myStart_1_Rng.Cells(iRow, 1).Value = Me.TextBox1.Text
Exit For
End If
Next iRow

End Sub



Patrick Simonds wrote:

TextBox1.Text = rng(1, "Start_1").Text

Start_1 is a range of cells ( AU3 :AU36) defined on the active worksheet.
I
want the text from TextBox1 to be placed into the Start_1 of the current
row.

I want to use Defined Names, so that over time if I have to add or
subtract
columns I will not have to go back and re-point all my references. The
code
I used before was TextBox1.Text = rng(1, 47).Text (this is just one of
dozens of lines code), but if I added or removed columns the references
all
had to be readjusted.


--

Dave Peterson



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Why does this not work?

What does it mean that you're on row 12?

Does that mean the activecell is in row 12?

dim myCell as range
on error resume next
set mycell = intersect(activecell, range("start_1"))
on error goto 0
if mycell is nothing then
'do nothing
else
mycell.value = textbox1.value
end if

maybe????????



Patrick Simonds wrote:

No, what I want to have happen is, if I am on row 12 I want the text to go
into the Start_1 on row 12. In this example start_1 would be cell AU12.

The dialog box which contains the text for Start_1 is displayed when I click
on a cell in column A. This worked well when I was using TextBox1.Text =
rng(1, 47), but now I have to have the ability to add or remove columns.

"Dave Peterson" wrote in message
...
It kind of sounds like you want the first empty cell in that range to get
the
value from your textbox.

If that's true, then you could do something like:

Option Explicit
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim myStart_1_Rng As Range

Set myStart_1_Rng = Worksheets("sheet1").Range("Start_1")

If Application.CountA(myStart_1_Rng) = myStart_1_Rng.Cells.Count Then
MsgBox "No empty cells in the range!"
Exit Sub
End If

For iRow = 1 To myStart_1_Rng.Rows.Count
If IsEmpty(myStart_1_Rng.Cells(iRow, 1)) Then
myStart_1_Rng.Cells(iRow, 1).Value = Me.TextBox1.Text
Exit For
End If
Next iRow

End Sub



Patrick Simonds wrote:

TextBox1.Text = rng(1, "Start_1").Text

Start_1 is a range of cells ( AU3 :AU36) defined on the active worksheet.
I
want the text from TextBox1 to be placed into the Start_1 of the current
row.

I want to use Defined Names, so that over time if I have to add or
subtract
columns I will not have to go back and re-point all my references. The
code
I used before was TextBox1.Text = rng(1, 47).Text (this is just one of
dozens of lines code), but if I added or removed columns the references
all
had to be readjusted.


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Why does this not work?

Okay Start_1 is defined as AU3:AU36, so in my spreadsheet I enter data on
rows 3 through 36, A1 A2 A3 ect.

If I click on cell A12 the data I enter into TextBox1 of the dialogbox is to
be placed in Start_1 which for this row would be AU12. So the data in
TextBox1 will always go to the Start_1 of the current row.

I appreciate your time and I hope that I am explaining this more clearly,
but if not please let me know.



"Dave Peterson" wrote in message
...
What does it mean that you're on row 12?

Does that mean the activecell is in row 12?

dim myCell as range
on error resume next
set mycell = intersect(activecell, range("start_1"))
on error goto 0
if mycell is nothing then
'do nothing
else
mycell.value = textbox1.value
end if

maybe????????



Patrick Simonds wrote:

No, what I want to have happen is, if I am on row 12 I want the text to
go
into the Start_1 on row 12. In this example start_1 would be cell AU12.

The dialog box which contains the text for Start_1 is displayed when I
click
on a cell in column A. This worked well when I was using TextBox1.Text =
rng(1, 47), but now I have to have the ability to add or remove columns.

"Dave Peterson" wrote in message
...
It kind of sounds like you want the first empty cell in that range to
get
the
value from your textbox.

If that's true, then you could do something like:

Option Explicit
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim myStart_1_Rng As Range

Set myStart_1_Rng = Worksheets("sheet1").Range("Start_1")

If Application.CountA(myStart_1_Rng) = myStart_1_Rng.Cells.Count
Then
MsgBox "No empty cells in the range!"
Exit Sub
End If

For iRow = 1 To myStart_1_Rng.Rows.Count
If IsEmpty(myStart_1_Rng.Cells(iRow, 1)) Then
myStart_1_Rng.Cells(iRow, 1).Value = Me.TextBox1.Text
Exit For
End If
Next iRow

End Sub



Patrick Simonds wrote:

TextBox1.Text = rng(1, "Start_1").Text

Start_1 is a range of cells ( AU3 :AU36) defined on the active
worksheet.
I
want the text from TextBox1 to be placed into the Start_1 of the
current
row.

I want to use Defined Names, so that over time if I have to add or
subtract
columns I will not have to go back and re-point all my references. The
code
I used before was TextBox1.Text = rng(1, 47).Text (this is just one of
dozens of lines code), but if I added or removed columns the
references
all
had to be readjusted.

--

Dave Peterson


--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Why does this not work?

I think my last suggestion would work for this situation.

Didn't it?

Patrick Simonds wrote:

Okay Start_1 is defined as AU3:AU36, so in my spreadsheet I enter data on
rows 3 through 36, A1 A2 A3 ect.

If I click on cell A12 the data I enter into TextBox1 of the dialogbox is to
be placed in Start_1 which for this row would be AU12. So the data in
TextBox1 will always go to the Start_1 of the current row.

I appreciate your time and I hope that I am explaining this more clearly,
but if not please let me know.

"Dave Peterson" wrote in message
...
What does it mean that you're on row 12?

Does that mean the activecell is in row 12?

dim myCell as range
on error resume next
set mycell = intersect(activecell, range("start_1"))
on error goto 0
if mycell is nothing then
'do nothing
else
mycell.value = textbox1.value
end if

maybe????????



Patrick Simonds wrote:

No, what I want to have happen is, if I am on row 12 I want the text to
go
into the Start_1 on row 12. In this example start_1 would be cell AU12.

The dialog box which contains the text for Start_1 is displayed when I
click
on a cell in column A. This worked well when I was using TextBox1.Text =
rng(1, 47), but now I have to have the ability to add or remove columns.

"Dave Peterson" wrote in message
...
It kind of sounds like you want the first empty cell in that range to
get
the
value from your textbox.

If that's true, then you could do something like:

Option Explicit
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim myStart_1_Rng As Range

Set myStart_1_Rng = Worksheets("sheet1").Range("Start_1")

If Application.CountA(myStart_1_Rng) = myStart_1_Rng.Cells.Count
Then
MsgBox "No empty cells in the range!"
Exit Sub
End If

For iRow = 1 To myStart_1_Rng.Rows.Count
If IsEmpty(myStart_1_Rng.Cells(iRow, 1)) Then
myStart_1_Rng.Cells(iRow, 1).Value = Me.TextBox1.Text
Exit For
End If
Next iRow

End Sub



Patrick Simonds wrote:

TextBox1.Text = rng(1, "Start_1").Text

Start_1 is a range of cells ( AU3 :AU36) defined on the active
worksheet.
I
want the text from TextBox1 to be placed into the Start_1 of the
current
row.

I want to use Defined Names, so that over time if I have to add or
subtract
columns I will not have to go back and re-point all my references. The
code
I used before was TextBox1.Text = rng(1, 47).Text (this is just one of
dozens of lines code), but if I added or removed columns the
references
all
had to be readjusted.

--

Dave Peterson


--

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
Macro to update a column in a work based on another work sheet WickerMan New Users to Excel 1 December 4th 09 12:58 PM
how can i automatically generate work order numbers from work orde rob h Excel Discussion (Misc queries) 1 July 13th 09 07:59 PM
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM


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