need to prevent pasting of wrong format

flyers2thecup

Active Member
Joined
Jul 29, 2004
Messages
362
I have a payment request spreadsheet that goes out to different business lines. On this form, are people who are getting incentive awards. I have to take the awards and save as .csv files and load the awards into peoplesoft. Some of the awards are based on sales. Therefore, some of the business lines use their own formulas to derive the amount that goes onto my template. But I need the awards to stay two decimal places. They are cutting and pasting and I get numbers like 1244.4596825. Is there a way to make a message popup to say, "The amount you are trying to paste is more than two decimal places. Please correct and enter a valid number."


Also, is there a way to lock just a CELL? not the sheet. I need them to be able to enter info...but some people change my formulas and it makes me very angry!!! :devilish: :devilish:

Thanks in advance!!!
 
You can do a dynamic range of rows by find the bottom row.
If you go down to cell A65536 and press ctrl-Up Arrow you will notice it takes you to the first row it finds. You can program this refrence by doing this:
Code:
Range("A65536").End(xlup).Address  
Or
Range("A65536").End(xlup).Row
So once you know that range you could then select a range of rows by doing something like:
Code:
Rows("2:"&Range("A65536").End(xlup).Row).Select
Or
Range("A2",Range("A65536").End(xlup)).Select
You can find a address in relation to another address by using offset. So say you knew your row is never more than 10 columns wide and you wanted to select just the 10 cells of the bottom row, you could do this:
Code:
Range(Range("A65536").End(xlUp), Range("A65536").End(xlUp).Offset(0, 10)).Select
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
excellent info. I'll give it a shot <GULP>! I'm done work for the day...so i'll get on it tomorrow. i'll post back with results...unless i blow up my machine in the process! :)

Thanks for the help!!!
 
Upvote 0
You don't need to worry about the decimals there.

This part of your code:

Code:
AwdAmt = Round(Cells(i, "e"), 2)

should take care of that for you, as it is the AwdAmt variable that is written to the .csv file in lieu of the cell value:

Code:
Tempstr = Cells(i, "a") & "," & Cells(i, "b") & "," & AwdAmt & "," _
                  & AwdAmt & "," & n & "," & n & "," & n & "," & Cells(i, "i")
        Print #FileNum, Tempstr
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

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