Hi,
I am very inexperienced on Excel and am currently trying to create a way in which i can check using a macro or some VBA code to see what cells have been chosen and once they are chosen they need to be pasted to another sheet. The problem I am having is that once more than 1 cell has been chosen i can't seem to work out how to paste multiple lines. The other problem i am having is that at the same time i need to be checking if something has already been pasted to the line on the other sheet and if so it needs to go down to the next row. I have found a way but there must be an easier way. The way this is looking i am going to end up with 1000's of lines of code and am just wondering if anyone has a tidier, more efficient way of doing this. I have included the code i have so far.
Please excuse the various mistakes i have more than likely unintentionally made.Sub Compiler() Sheets("Red X Customer List").Select If Range("N4").Value = True Then Range("A4:L4").Select Application.CutCopyMode = False Selection.Copy Sheets("Weekly Sheet").Select Range("A5").Select If Range("A5").Value = 0 Then ActiveSheet.Paste Sheets("Red X Customer List").Select ElseIf Range("A6").Value = 0 Then Range("A6").Select ActiveSheet.Paste Sheets("Red X Customer List").Select ElseIf Range("A7").Value = 0 Then Range("A7").Select ActiveSheet.Paste Sheets("Red X Customer List").Select If Range("N5").Value = True Then Range("A5:L5").Select Application.CutCopyMode = False Selection.Copy Sheets("Weekly Sheet").Select Range("A5").Select If Range("A5").Value = 0 Then ActiveSheet.Paste Sheets("Red X Customer List").Select ElseIf Range("A6").Value = 0 Then Range("A6").Select ActiveSheet.Paste Sheets("Red X Customer List").Select ElseIf Range("A7").Value = 0 Then Range("A7").Select ActiveSheet.Paste Sheets("Red X Customer List").Select End If End If End If End If End Sub
Many Thanks,
Gareth
Last edited by Richard Buttrey; 01-05-2012 at 09:59 AM. Reason: Code tags added - please note
Hi Gareth,
As this is your first post you'll note that I've just edited it for you so that the code is now wrapped between code tags - please note our rules on this.
You would be better uploading your workbook and describing with reference to specific cells ranges and sheets precisely what you are trying to achieve, giving examples of the results you expect. It's likely that your code is not the best way of proceeding and we will only waste time trying to reverse engineer what is deficient code anyway, in an attempt to see what you want.
Regards
Richard Buttrey
If this was useful then please rate it appropriately.
Click the small star iconat the bottom left of my post.
Hi,
Sorry for the intiail mistake i'll make sure to put the code tags on next time.
Below is a description i am hoping to achieve along with a link to the spreadsheet.
I am extremely inexperienced in Excel but i am doing my best to currently create a spreadsheet that has hundreds of companies with tick boxes next to them. Once the rows that i want pasted are checked I want to be able to hit a button at the bottom of the sheet to copy these rows to another sheet. I'm not sure which way to go about it, whether there is a way of perhaps selecting multiple lines and copy and pasting them or doing it line by line.
I have opted initially to do it line by line as with my current knowledge I feel this is probably the only way in which i may finish this. The problem i'm having is that I can't seem to copy and paste more than 1 checked row and even if i could I don't know how to find the next empty row on the other sheet. I have potentially found a way but this will involve an IF statement for every line and there must be an easier way surely?
I've added a link to my workbook below and in basic terms what i have come up with is;
IF M4=True then
(A4:K4).copy
WeeklySheet.Selection
IF A5="" Then
Paste
Elseif A6="" Then
And so on and so on.
I realise that this may be extremely easy for someone that knows what they're doing but a nudge in the right direction would be much appreciated.
Many thanks in advance,
Gareth
http://www.filefactory.com/file/c1fdbef/n/RedXtest.xls
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks