Automatic data update macro running absolutely fine, just not pasting

Siddie

New Member
Joined
Jan 20, 2018
Messages
1
The code below runs/loops just fine and pastes the cells(7,9) to the other sheet. It also pops up and stops the msg box on meeting a blank cell. However, other than that first cell there is no other cell on the target sheet that is being populated. I've tried assigning values directly through another string as well, no-fun!, the only data it transfers is the first cell.

Also, I would be glad to further shorten this code ... :cool:

Any help will be cordially appreciated ... :rolleyes:

Private Sub CommandButton2_Click()


Dim L As Integer
Dim aData As String
'Dim bData As String
Dim myCell As Range
L = 7
'activate the control panel
Worksheets("Review & Update").Activate


'Assigning the data and cell location to strings
aData = Cells(L, 6).Value
'bData = Cells(L, 9).Value
Do
' Action
Cells(L, 9).Select
If Cells(L, 9).Value = "" Then
MsgBox "Opps! we met a blank cell"
Exit Do
Else
Cells(L, 9).cOpy
Set myCell = Sheets("attendance").Range(aData)
' Goto proper sheet/address
Worksheets("Attendance").Activate
myCell.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'myCell.Value = bData
L = L + 1
Worksheets("Review & Update").Activate
End If
Loop
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
This needs to be inside the Do...Loop :

aData = Cells(L, 6).Value

'bData = Cells(L, 9).Value
 
Upvote 0
Also, I would be glad to further shorten this code ... :cool:

Does column 9 contain formulas or constants ?
Are the cell refs in column 6 sequential (e.g. D5,D6,D7,....) ?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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