Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Setting the text in a cell to the text of a cell on a different sheet in the same workbook

OK, the subject should say a lot about my Excel programming experience.
I'm quite the flaming novice. :)

I'm trying to change the text in a sheet named "Cert" on a cell
starting in column C to the text in a cell in another sheet in the same
workbook named "Info" when the cells in the A column change. I was
thinking this should be really easy and doable in 2 or 3 lines.

Here's what I came up with:

If Not Intersect(Target, Range("A14:A35")) Is Nothing Then
Range("C:" & Target.Row).Text = sheets("Info") ... and then the
cell, based on target cell's value.

It's the part after the "=" that I think is really getting me. It
can't be that hard... but I'm managing to make it so. Any advice would
be greatly appreciated.

Max.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Setting the text in a cell to the text of a cell on a different sheet in the same workbook

Text is a read only property

Also, you cleverly left out any explanation of how to use the value of
Target to determine the appropriate cell in Info. I will assume it is a
named range.

If Not Intersect(Target, Range("A14:A35")) Is Nothing Then
Range("C" & Target.Row).Value = sheets("Info").Range(Target.Value).Text
end if

Note several changes to your original code.

--
Regards,
Tom Ogilvy


"Max C" wrote in message
ups.com...
OK, the subject should say a lot about my Excel programming experience.
I'm quite the flaming novice. :)

I'm trying to change the text in a sheet named "Cert" on a cell
starting in column C to the text in a cell in another sheet in the same
workbook named "Info" when the cells in the A column change. I was
thinking this should be really easy and doable in 2 or 3 lines.

Here's what I came up with:

If Not Intersect(Target, Range("A14:A35")) Is Nothing Then
Range("C:" & Target.Row).Text = sheets("Info") ... and then the
cell, based on target cell's value.

It's the part after the "=" that I think is really getting me. It
can't be that hard... but I'm managing to make it so. Any advice would
be greatly appreciated.

Max.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Setting the text in a cell to the text of a cell on a different sheet in the same workbook

Hey Tom. Thanks for the reply. I tried something nearly exactly like
what you wrote below, only I was using the actual code to select the
range I want. Basically, when the user types in a number on the Cert
page in Column A, I use it to grab the description from a corresponding
line on the Info page from Range DXX:JXX. Every time I'd enter
something on the info page, though, I'd get the error "the method of
range class failed."

I have a new problem, though. I saved my workbook and closed Excel
last night. This morning when I went in to try your suggestion, the
workbook won't run the Macro I wrote when I change a value on the A
column on the Cert sheet. I'll keep plugging away at it. Believe it
or not, 10 years ago I was pretty good at writing Excel Macros. I was
even MS certified in VB. Just goes to show... if you don't use it,
you'll loose it.

Thanks for your help.
Max.

Tom Ogilvy wrote:
Text is a read only property

Also, you cleverly left out any explanation of how to use the value of
Target to determine the appropriate cell in Info. I will assume it is a
named range.

If Not Intersect(Target, Range("A14:A35")) Is Nothing Then
Range("C" & Target.Row).Value = sheets("Info").Range(Target.Value).Text
end if

Note several changes to your original code.

--
Regards,
Tom Ogilvy


Tom, thanks for the reply

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Setting the text in a cell to the text of a cell on a different sheet in the same workbook

OK, getting back in to this. I can't believe this is turning out to be
so hard for me. It's more than a little embarassing. Here's what I
have so far:
__________________________________________________ __________
Private Sub Worksheet_Change(ByVal Target As Range)
Dim SelectedText As String

If Not Intersect(Target, Range("A14:A35")) Is Nothing Then
SelectedText = Sheets("Info").Range("D" & (Target.Value + 24) &
":J" & (Target.Value + 24)).Text
Range("C" & Target.Row & ":I" & Target.Row).Text = SelectedText
End If

End Sub
__________________________________________________ __________

I realize the string variable is unnecessary, but it helps me see it
better. The thing is, the variable assignment line doesn't work. I
get Error 94: Invalid use of Null. Is there no such thing as a Text
property for a range of cells?

By the way, I'm using ranges of cells because in this workbook the 2
ranges holding text are merged cells. When I ran the macro recorder
and selected one of those merged cell blocks, the recorder showed I
selected a range of cells. Maybe that's my problem?

Thanks for looking again.
Max.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Setting the text in a cell to the text of a cell on a different sheet in the same workbook

And dang it! Every time I save and close a workbook with this code in
it, when I reopen the workbook, the change event stops firing. Once
again I don't even get an error message when I change something in
column A. What's the deal?!

Max.


Max C wrote:
OK, getting back in to this. I can't believe this is turning out to be
so hard for me. It's more than a little embarassing. Here's what I
have so far:
__________________________________________________ __________
Private Sub Worksheet_Change(ByVal Target As Range)
Dim SelectedText As String

If Not Intersect(Target, Range("A14:A35")) Is Nothing Then
SelectedText = Sheets("Info").Range("D" & (Target.Value + 24) &
":J" & (Target.Value + 24)).Text
Range("C" & Target.Row & ":I" & Target.Row).Text = SelectedText
End If

End Sub
__________________________________________________ __________

I realize the string variable is unnecessary, but it helps me see it
better. The thing is, the variable assignment line doesn't work. I
get Error 94: Invalid use of Null. Is there no such thing as a Text
property for a range of cells?

By the way, I'm using ranges of cells because in this workbook the 2
ranges holding text are merged cells. When I ran the macro recorder
and selected one of those merged cell blocks, the recorder showed I
selected a range of cells. Maybe that's my problem?

Thanks for looking again.
Max.




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
grab cell text from multi-tab workbook, show text in another workb pfa Excel Worksheet Functions 16 August 10th 07 08:50 PM
Setting a cell reference in one sheet that updates a workbook? Danhalawi Excel Discussion (Misc queries) 1 November 7th 06 04:08 PM
select text in cell based on text from another cell, paste the text at the begining of a thrid cell, etc... jsd219 Excel Programming 0 October 19th 06 05:04 PM
Setting the Chart name as the text from a cell. Sareh Excel Programming 2 July 17th 06 07:41 PM
Setting spaces between text in a cell Erik K via OfficeKB.com[_2_] Excel Programming 8 November 4th 05 10:23 AM


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