Hello,
I have literally started learning basic VBA this week. So far all my codes are immensely long lists of copy and pasting and I'm more than sure it can be condensed down
Literally my code is:
... for every cell I want to copy for every day. It's a slow learning process here. I found a generic example and just played about till something happened.
I'm trying to copy values from a sheet named 'Dashboard' to two other sheets, 'Key Out' and 'Order History'.
The 'Key Out' I've managed... albeit it with a billion lines of repetitive code, as above.
I'm trying to now do the same again from 'Dash Board' to 'Order History' but- only if row 11 has a value equal to or higher than 0.
So far it is exactly the same as above and I cannot get my head around the condition part (and I'd like to really cut it down).
At the moment it makes sense to me with the notes and the format, which is fine whilst I'm learning but it is soooooooooo long.
Is it possible to get a generic basic code I could use, that is pretty simplified for my little brain to play about with that will help me with my project whilst I get to grips with this, I've found quite a few codes that would do what I'm asking but I can't for the life of me get it to do a thing.
Thank you oodles in advance!
I have literally started learning basic VBA this week. So far all my codes are immensely long lists of copy and pasting and I'm more than sure it can be condensed down
Literally my code is:
Code:
Private Sub KEY_OUT_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("Dashboard")
Set pasteSheet = Worksheets("Order History")
'---------- Key Out Data - Midas Code and Week Day Order Gen --------------------
'--------- Todays Date When Generated -------------------------------------------
copySheet.Range("B5").Copy
pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'---------- Midas Code ----------------------------------------------------------
copySheet.Range("c5").Copy
'Mon
pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
'Tues
pasteSheet.Cells(Rows.Count, 5).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
'Weds
pasteSheet.Cells(Rows.Count, 8).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
'Thurs
pasteSheet.Cells(Rows.Count, 11).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
'Fri
pasteSheet.Cells(Rows.Count, 14).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
'Sat
pasteSheet.Cells(Rows.Count, 17).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
'Sun
pasteSheet.Cells(Rows.Count, 20).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'---------- Week Day Order Gens ------------------------------------------------
'Mondays order gen
copySheet.Range("c11").Copy
pasteSheet.Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'Tuesdays order gen
copySheet.Range("d11").Copy
pasteSheet.Cells(Rows.Count, 6).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'Wednesdays order gen
copySheet.Range("e11").Copy
pasteSheet.Cells(Rows.Count, 9).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'Thursdays order gen
copySheet.Range("f11").Copy
pasteSheet.Cells(Rows.Count, 12).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'Fridays order gen
copySheet.Range("g11").Copy
pasteSheet.Cells(Rows.Count, 15).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'Saturdays order gen
copySheet.Range("h11").Copy
pasteSheet.Cells(Rows.Count, 18).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
'Sundays order gen
copySheet.Range("i11").Copy
pasteSheet.Cells(Rows.Count, 21).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
... for every cell I want to copy for every day. It's a slow learning process here. I found a generic example and just played about till something happened.
I'm trying to copy values from a sheet named 'Dashboard' to two other sheets, 'Key Out' and 'Order History'.
The 'Key Out' I've managed... albeit it with a billion lines of repetitive code, as above.
I'm trying to now do the same again from 'Dash Board' to 'Order History' but- only if row 11 has a value equal to or higher than 0.
So far it is exactly the same as above and I cannot get my head around the condition part (and I'd like to really cut it down).
At the moment it makes sense to me with the notes and the format, which is fine whilst I'm learning but it is soooooooooo long.
Is it possible to get a generic basic code I could use, that is pretty simplified for my little brain to play about with that will help me with my project whilst I get to grips with this, I've found quite a few codes that would do what I'm asking but I can't for the life of me get it to do a thing.
Thank you oodles in advance!
Last edited by a moderator: