Excel macro for copy & paste selected range
Solved/Closed
Related:
- Excel macro for copy & paste selected range
- Excel apk for pc - Download - Spreadsheets
- How to take screenshot of selected area in excel - Guide
- Spell number in excel without macro - Guide
- Kernel for excel - Download - Backup and recovery
- Excel marksheet - Guide
2 responses
This macro uses an inputbox to ask what month you are updating. Use numeric values instead of typing in the month. Example: Jan. =1, Feb. = 2, Mar. = 3. I am assuming you would not want to update January so the macro will exit if 1 is typed in the inputbox (unless it is updated from December then we can change it).
Hope this helps.
Sub Update_Month()
Dim answer As Variant
Dim j
j = 3
answer = InputBox("What month are you updating?" & vbCrLf & _
"Ex: January =1, February = 2, March=3, etc.")
Select Case answer
Case 1
Exit Sub
Case 2
For j = 3 To 6
Range("B" & j) = Range("A" & j)
Next j
Case 3
For j = 3 To 6
Range("C" & j) = Range("B" & j)
Next j
Case 4
For j = 3 To 6
Range("D" & j) = Range("C" & j)
Next j
Case 5
For j = 3 To 6
Range("E" & j) = Range("D" & j)
Next j
Case 6
For j = 3 To 6
Range("F" & j) = Range("E" & j)
Next j
Case 7
For j = 3 To 6
Range("G" & j) = Range("F" & j)
Next j
Case 8
For j = 3 To 6
Range("H" & j) = Range("G" & j)
Next j
Case 9
For j = 3 To 6
Range("I" & j) = Range("H" & j)
Next j
Case 10
For j = 3 To 6
Range("J" & j) = Range("I" & j)
Next j
Case 11
For j = 3 To 6
Range("K" & j) = Range("J" & j)
Next j
Case 12
For j = 3 To 6
Range("L" & j) = Range("K" & j)
Next j
End Select
End Sub
Hope this helps.
Sub Update_Month()
Dim answer As Variant
Dim j
j = 3
answer = InputBox("What month are you updating?" & vbCrLf & _
"Ex: January =1, February = 2, March=3, etc.")
Select Case answer
Case 1
Exit Sub
Case 2
For j = 3 To 6
Range("B" & j) = Range("A" & j)
Next j
Case 3
For j = 3 To 6
Range("C" & j) = Range("B" & j)
Next j
Case 4
For j = 3 To 6
Range("D" & j) = Range("C" & j)
Next j
Case 5
For j = 3 To 6
Range("E" & j) = Range("D" & j)
Next j
Case 6
For j = 3 To 6
Range("F" & j) = Range("E" & j)
Next j
Case 7
For j = 3 To 6
Range("G" & j) = Range("F" & j)
Next j
Case 8
For j = 3 To 6
Range("H" & j) = Range("G" & j)
Next j
Case 9
For j = 3 To 6
Range("I" & j) = Range("H" & j)
Next j
Case 10
For j = 3 To 6
Range("J" & j) = Range("I" & j)
Next j
Case 11
For j = 3 To 6
Range("K" & j) = Range("J" & j)
Next j
Case 12
For j = 3 To 6
Range("L" & j) = Range("K" & j)
Next j
End Select
End Sub
Mar 11, 2009 at 09:34 PM
Thanks very much for the code - it worked beautifully! Although it worked differently to what I'd expected, it actually gave me a good idea to improve my overall summary sheet.
Thanks again - you are a legend!
Cheers
DitzySuz
Jun 7, 2010 at 05:45 PM
I have similar issue.
Instead of going horizontal, I need to go vertical.
I have few data, and I need to update the rows daily by adding new row, and pasting the value of previous data and updating the current row. I have about 15 different sub-set of rows that needs to be updated daily.
do you think you will be able to help me out?
Jul 8, 2011 at 07:08 AM
Sub Button924_Click()
Dim answer As Variant
Dim j
j = 3
answer = InputBox("What month are you updating?" & vbCrLf & _
"E.g. Feb = 2, Mar = 3, Apr = 4, May = 5 ... etc")
Select Case answer
Case 1
Exit Sub
Case 2
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("G8:G400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 3
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("H8:H400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 4
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("I8:I400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 5
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("J8:J400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 6
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("K8:K400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 7
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("L8:L400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 8
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("M8:M400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 9
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("N8:N400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 10
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("O8:O400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 11
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("P8:P400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
Case 12
For j = 8 To 8
Range("F8:F400").Select
Selection.Copy
Range("Q8:Q400").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Next j
End Select
End Sub