nithin shettigar

New Member
Joined
Mar 16, 2014
Messages
44
I am getting debug error in (Set myRng = .Range(myCopy))
Sub UpdateLogWorksheet()
Dim warning As Integer


warning = MsgBox("Data Updated Cannot be Modified", vbYesNo + vbQuestion, "NOTE")


If warning = vbYes Then


Application.ScreenUpdating = False
Sheets("Database").Visible = True



Dim historyWks As Worksheet
Dim inputWks As Worksheet


Dim nextRow As Long
Dim oCol As Long


Dim myRng As Range
Dim myCopy As String
Dim myCell As Range

'cells to copy from Input sheet - some contain formulas
myCopy = "N6,F7,F6,N5,N4,F5,J10,D29,D28,N7,Q7,R7,N29,N27,Q27,R27,H28,I28,J28,K28,S28,N28,Q28,R28,D27,D25,I25,N25,D22,E23,N22,Q22,R22,I23,N23,Q23,R23,D21,I21,N21,D18,V10,V12,J19,K19,S18,N18,Q18,R18,V25,V27,J17,K17,S17,N16,Q16,R16,D14,I14,J14,N14,Q14,R14,M10,V5,V7,J13,K13,S13,N13,Q13,R13,N11,D9"


Set inputWks = Worksheets("Input")
Set historyWks = Worksheets("Database")


With historyWks
nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
End With


With inputWks
Set myRng = .Range(myCopy)


If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox "Incomplete Data-Please fill in all the Entries!"
Exit Sub
End If
End With


With historyWks
With .Cells(nextRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(nextRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(nextRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With
'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConstants)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With
Else
'do nothing
End If


Sheets("Database").Visible = False
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
hi
try to
Code:
Set myRng = Union(Range("a1"), Range("b4")) as an example
 
Upvote 0

Forum statistics

Threads
1,213,513
Messages
6,114,072
Members
448,546
Latest member
KH Consulting

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