valuenumbers need to be pasted in a specific cell

sey

New Member
Joined
Apr 28, 2011
Messages
35
Hi,

I have a question, first i search with a lookup some valuenumbers.
But then the valuenumbers need to be pasted in a specific cell.

As example:
If the valuenumber is between 0-50 then it need to be pasted in Cell("A2")

If the valuenumber is between 50-100 then it need to be pasted in cell("A3")

if the ....


Anyone has an idea how i can do this?


Kind Regards
Sey
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
If you don't want to look for the whole code, just an idea is enough, i don't know how to begin at this.
 
Upvote 0
Try this to copy the value in cell A1

Code:
Sub test()
Range("A" & Int(Range("A1").Value / 50) + 2).Value = Range("A1").Value
End Sub
 
Upvote 0
This is using cell A1 as the result of the lookup value;
Code:
Sub LookupPaste()
Select Case Range("A1").Value
Case Is < 50
Range("A2").Value = Range("A1").Value
Case Is < 100
Range("A3").Value = Range("A1").Value
End Select

End Sub

Adjust ranges to suit,

HTH
Colin
 
Upvote 0
Thank you, everything u peolpe reply i can maybe use.

Because this is my project:

I have a worksheet with all the dimensions of a workpiece.

with a lookup i will search the dimensions and paste them on a specific place by a image of the section of that workpiece (specific place it's on scale 50, so if he finds 27, it will be placed in cell 0-50, it doesn't need to be that correct).
So i gived every cell a name like:

section50 ( for a number between 0-50)
section100 (for a number between 50-100)

I was thinking of:

First i give every cell a name around that image (section50, section100,...)

then i search with lookup the numbers, if he find 20 then he putt it in cell("section50")

but i dont know good code for put the numbers in the correct cell. or are there better solutions?
 
Upvote 0
Thank you very much, it's getting better and better
But my look up found 3030 and pasted it in section100 ? did i something wrong?
here you see some code (from section 0-300)

Code:
Sub LookupPaste()
'Select Case Range("A1").Value
'Case Is < 50
'Range("A2").Value = Range("A1").Value
'Case Is < 100
'Range("A3").Value = Range("A1").Value
'End Select
Dim acell As Range
Sheets("kwnie").Activate
Range("D20").Name = "section100"
Range("E20").Name = "section200"
Range("F21").Name = "section300"
Sheets("SETUP").Activate
For Each acell In Range("eer")
If IsEmpty(acell) Then
Else
ActiveCell.copy
Sheets("kwnie").Activate
Select Case Range("afmt100").Value
Case Is < 100
Range("section200").Value = Range("section100").Value
Case Is < 200
Range("section300").Value = Range("section100").Value
End Select
ActiveCell.PasteSpecial
End If
Next acell
End Sub
This is using cell A1 as the result of the lookup value;
Code:
Sub LookupPaste()
Select Case Range("A1").Value
Case Is < 50
Range("A2").Value = Range("A1").Value
Case Is < 100
Range("A3").Value = Range("A1").Value
End Select
 
End Sub

Adjust ranges to suit,

HTH
Colin
 
Upvote 0
You need to add more case statements;

Code:
Select Case Range("afmt100").Value
Case Is < 100
Range("section200").Value = Range("section100").Value
Case Is < 200
Range("section300").Value = Range("section100").Value
Case Is < 300
Range("section400").Value = Range("section100").Value
Case Is < 400
Range("section500").Value = Range("section100").Value
Case Is < 500
Range("section600").Value = Range("section100").Value
Case Else
'Whatever'
End Select

HTH
Colin
 
Upvote 0
Sorry, I've just edited this bit of code;
Code:
Select Case Range("afmt100").Value
Case Is < 100
Range("section200").Value = Range("section100").Value
Case Is < 200
Range("section300").Value = Range("section200").Value
Case Is < 300
Range("section400").Value = Range("section300").Value
Case Is < 400
Range("section500").Value = Range("section400").Value
Case Is < 500
Range("section600").Value = Range("section500").Value
Case Else
'Code for Whatever else'
End Select

I'm not 100% sure of what you are trying to do, but if you can't adapt the code with more case statements, then post back with more info and we will see if we can help.

HTH
Colin
 
Upvote 0
Thank you for help, but i didn'y find it with cases, so i tried other things and found a solution.

Thanks anyway!

Sorry, I've just edited this bit of code;
Code:
Select Case Range("afmt100").Value
Case Is < 100
Range("section200").Value = Range("section100").Value
Case Is < 200
Range("section300").Value = Range("section200").Value
Case Is < 300
Range("section400").Value = Range("section300").Value
Case Is < 400
Range("section500").Value = Range("section400").Value
Case Is < 500
Range("section600").Value = Range("section500").Value
Case Else
'Code for Whatever else'
End Select

I'm not 100% sure of what you are trying to do, but if you can't adapt the code with more case statements, then post back with more info and we will see if we can help.

HTH
Colin
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,553
Members
452,928
Latest member
101blockchains

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