help please! I really need to figure this out

d0wnt0wn

Well-known Member
Joined
Oct 28, 2002
Messages
771
I have tried leaving a post on this in another thread but i cant seem to get any responce to this.... sorry it is very important that I get this done

i wouldl like to have some code that works like this....

sheet 1 cell a1 if i enter a number from 1 to 10 I copy cell b1-b10 (depending on which number i put in a1) on sheet 2 and paste it into B1 on sheet 1

seems like it should be easy to me but i cant seem to get any responces on it any help would be greatly appreciated.... and I have to use code for this as a vlookup will not get me what i want
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
d0wnt0wn, please post which thread(s) you are referring to and some more specifics on your question. What do the numbers mean in terms of coding a solution? Can you provide some examples?
 
Upvote 0
Try entering in cell B1 in sheet 1:

=INDEX(Sheet2!B1:B10,A1)

Then enter 1-10 as you describe. If you enter a number in A1 outside the range you specifie you will receive an error in B1.

Andywiz
 
Upvote 0
yes kristy it would be the same...... sorry for the double post but i am really under the gun to get this done
 
Upvote 0
How's this:

<font face=tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)
    <SPAN style="color:#00007F">Dim</SPAN> rng <SPAN style="color:#00007F">As</SPAN> Range
     <SPAN style="color:#007F00">'   Only look at single cell changes</SPAN>
    <SPAN style="color:#00007F">If</SPAN> Target.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
    <SPAN style="color:#00007F">Set</SPAN> rng = Range("A1")
    <SPAN style="color:#007F00">'   Only look at that range</SPAN>
    <SPAN style="color:#00007F">If</SPAN> Intersect(Target, rng) <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
        <SPAN style="color:#00007F">If</SPAN> Target.Value >= 1 And Target.Value <= 10 <SPAN style="color:#00007F">Then</SPAN>
            Range("B" & Target.Value).Copy Sheets("Sheet2").Range("B1")
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

HTH,

Smitty
 
Upvote 0
andy...... thanks but i actually need the cell to be copy pasted and not just get the info from the cell


fire.... basically i am trying to do this.....

i want to select the name of a picture from a drop down menu

then i want the picture to appear beside my selection and then next to that a description of the picture

i thought that by inserting a picture into a comment i could relate that picture to a cell... then if i just copy and paste that cell with the comment in it and turn comment indicators on then the picture would appear... this is probably the wrong way to go about things but it seemed to make sense to me.
 
Upvote 0
hi smitty thanks for the responce

i see where you are going with this but i need something a little more

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
' Only look at single cell changes
If Target.Count > 1 Then Exit Sub
Set rng = Range("A1")
' Only look at that range
If Intersect(Target, rng) Is Nothing Then Exit Sub
If Target.Value >= 1 And Target.Value <= 10 Then
Range("B" & Target.Value).Copy Sheets("Sheet2").Range("B1")
End If
End Sub


if target value =1 then copy sheet2 b1
if targetvalue =2 then copy sheet2 b2

etc

but also id like the same dropdown in A1 through A10 on sheet 1 to work not just the A1 range
 
Upvote 0
Couldn't you change this:
Code:
Range("B" & Target.Value).Copy Sheets("Sheet2").Range("B1")
to:
Code:
Range("B" & Target.Value).Copy Sheets("Sheet2").Range("B" & Target.Value)
Smitty
 
Upvote 0
smitty i tried the code you gave me just to test it and when i enter something into a1 on sheet 1..... whatever i had on sheet2 b1 vanishes and nothing pastes to sheet 1
 
Upvote 0

Forum statistics

Threads
1,215,657
Messages
6,126,057
Members
449,284
Latest member
fULMIEX

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