Help! Excel VB refer on cell and macro question, I dunno how to explain it in word

radian89

Board Regular
Joined
Nov 12, 2015
Messages
113
I have this condition

as you can see in the image,
1. D3 are need data from B3 with formula =$B$3 & " and Indonesia"

2. I need to make B7 until B15, when i type "USA","Australia",etc in those cell one by one it'll do task like point no 1, so the result will be "USA and Indonesia"

example : I type "USA" in B7, then B3 change to "USA", then D3 become "USA and Indonesia"


3. after point 2 done, when i press enter, B7 will automatically copy and paste as value from D3, and this command/procedure can be done repeatedly.

example : after type "USA" and press enter, D3 > copy > paste as value > B7 > B7 become "USA and Indonesia", then i'll go to B8 to do the same procedure from step 2 to 3

for point 3, can i just use record macro?
it sounds simple, but my hair just falling apart because of this.... very big thanks for the help...

2w3oll4.jpg
[/IMG]
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hope this helps.
Sheet module

Code:
Private Sub Worksheet_Change(ByVal Target As Range)  
   If Intersect(Target, Range("B7:B15")) Is Nothing Then
        Exit Sub
    Else
        Application.EnableEvents = False
        Target.Value = Target & "Indonesia"
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
Hi Takae

Thank you for the help,
Hope this helps.
Sheet module

Code:
Private Sub Worksheet_Change(ByVal Target As Range)  
   If Intersect(Target, Range("B7:B15")) Is Nothing Then
        Exit Sub
    Else
        Application.EnableEvents = False
        Target.Value = Target & "Indonesia"
    End If
    Application.EnableEvents = True
End Sub

almost correct, but the procedure must follow
1. when we type in B7 "USA" >> B3 will also change to "USA" >> then D3 will become "USA and Indonesia"
2. after D3 become "USA and Indonesia" >> command copy and paste as value in "B7", so it become "USA and Indonesia"

it'll applied to B7 until B15


warm regards
Adrian
 
Upvote 0
Try it.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Intersect(Target, Range("B7:B15")) Is Nothing Then
        Exit Sub
    Else
        Application.EnableEvents = False
        Range("B3").Value = Target.Value
        Range("D3").Value = Target & "Indonesia"
        Target.Value = Target & "Indonesia"
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0
HURRAY..... I'm so happy :biggrin:

どうもありがとうございます

Thanks a lot Takae

you just made my day :)... need your help again in the future...

will you explained it to me, the logic behind this command (in bold)? i'm still trying to understand it


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B7:B15")) Is Nothing Then
Exit Sub
Else

Application.EnableEvents = False
Range("B3").Value = Target.Value
Range("D3").Value = Target & "Indonesia"
Target.Value = Target & "Indonesia"
End If
Application.EnableEvents = True
End Sub
</pre>
Try it.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Intersect(Target, Range("B7:B15")) Is Nothing Then
        Exit Sub
    Else
        Application.EnableEvents = False
        Range("B3").Value = Target.Value
        Range("D3").Value = Target & "Indonesia"
        Target.Value = Target & "Indonesia"
    End If
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,539
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top