ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change Event Range Help (https://www.excelbanter.com/excel-programming/357533-change-event-range-help.html)

mastermind

Change Event Range Help
 
I need a change event macro that fires any time there is a change on
the range G11:G30. I need to the macro to take the name in the G
column and make it the name of the 4 cells directly to the right (H-K).
If someone can figure out how to do that for me that would be great.


G H I ....K
11 Cars Ford Ranger BMW
12 Movies Harry Potter Red Eye
.... ... ... ...
.... ... ... ...
.... ... ... ...
.... ... ... ...
.... ... ... ...
30 Computers Dell IBM


Tom Ogilvy

Change Event Range Help
 
Do you mean create a Named Range


Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if target.count 1 then exit sub
if not intersect(target,Range("G11:G30")) is nothing then
if Not isempty(Target) then
Target.Offset(0,1).Resize(1,4).Name = Target
end if
End if
End Sub

--
Regards,
Tom Ogilvy


"mastermind" wrote in message
oups.com...
I need a change event macro that fires any time there is a change on
the range G11:G30. I need to the macro to take the name in the G
column and make it the name of the 4 cells directly to the right (H-K).
If someone can figure out how to do that for me that would be great.


G H I ....K
11 Cars Ford Ranger BMW
12 Movies Harry Potter Red Eye
... ... ... ...
... ... ... ...
... ... ... ...
... ... ... ...
... ... ... ...
30 Computers Dell IBM




mastermind

Change Event Range Help
 
Well, that worked pretty well. The only problem is, is that when I
enter a topic like "Frontend Loaders" it produces an error. However,
if I highlight a set of cells and manually name them "Frontend_Loader"
everything is okay. What is causing this error, and how can I fix it?
Also will this work with "(" ")" in the topic cell?


Dave Peterson

Change Event Range Help
 
Names can't have spaces in them.

Target.Offset(0,1).Resize(1,4).Name = Target
could be replaced (maybe???) with:
Target.Offset(0,1).Resize(1,4).Name = application.substitute(Target," ","_")

But there are other things that you could type that would also be invalid --
things that look like cell addresses for example.

mastermind wrote:

Well, that worked pretty well. The only problem is, is that when I
enter a topic like "Frontend Loaders" it produces an error. However,
if I highlight a set of cells and manually name them "Frontend_Loader"
everything is okay. What is causing this error, and how can I fix it?
Also will this work with "(" ")" in the topic cell?


--

Dave Peterson


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com