Duplicating the ActiveCell

Tripss

New Member
Joined
Jun 5, 2019
Messages
3
I want to duplicate the active cell to specific cells on a calendar and everything seems to be right but my code as is does absolutely nothing. I added in a msgbox just to make sure that it is picking up the value of the active cell and it is however it cant seem to print it in the other cells. My code is as follows:


Sub DuplicateEverydayWholeMonth()

Dim locr As Integer
Dim locc As Integer
Dim duccounter As Integer
Dim durcounter As Integer
Dim desc As String

locr = ActiveCell.Row
locc = ActiveCell.Column
duccounter = 4
durcounter = 0
desc = ActiveCell.Value

Do While locr < wcounter
Do While locc <= 17
ActiveCell.Offset(durcounter, duccounter).Value = desc
duccounter = duccounter + 4
locc = locc + 4
Loop

If ActiveCell.Column = 2 Or 6 Or 10 Or 14 Then
locc = 2
ElseIf ActiveCell.Column = 3 Or 7 Or 11 Or 15 Then
locc = 3
ElseIf ActiveCell.Column = 4 Or 8 Or 12 Or 16 Then
locc = 4
ElseIf ActiveCell.Column = 5 Or 9 Or 13 Or 17 Then
locc = 5
Else
MsgBox ("Invalid Cell Selection")
Exit Sub
End If

locr = locr + 10
durcounter = durcounter + 10
Loop
MsgBox (desc)
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I'm glad to help you.
Let's forget for a moment the code, explain with examples what you want to do.
 
Upvote 0
The code is supposed to duplicate text from the Active cell into other cells based the variables durcounter and duccounter. I think there is a problem with the syntax in the ActiveCell.Offset line. Please advise.
 
Upvote 0
Though I don't understand your overall code, because nothing is getting assigned to the wcounter variable the code always bypasses the loop and goes straight to the message box i.e. this line is True at the start of the code:

Code:
Do While locr < wcounter

Step through the code (by pressing F8 from within the macro) to see what I mean if you're not sure.

HTH

Robert
 
Upvote 0
The code is supposed to duplicate text from the Active cell into other cells based the variables durcounter and duccounter. I think there is a problem with the syntax in the ActiveCell.Offset line. Please advise.


As I told you, forget the code, explain where you want to paste the cell, and the conditions to determine where to paste the cell.
 
Upvote 0
Though I don't understand your overall code, because nothing is getting assigned to the wcounter variable the code always bypasses the loop and goes straight to the message box i.e. this line is True at the start of the code:

Code:
Do While locr < wcounter

Step through the code (by pressing F8 from within the macro) to see what I mean if you're not sure.

HTH

Robert

The wcounter is a public variable calculated in another sub I have put in msgbox(wcounter) and it reads the correct value for wcounter. Which is either 40, 50 or 60 depending on if the user wants 4, 5 or 6 weeks on their calendar. Stepping through my code shows it is looping properly.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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