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
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

mohadin

Well-known Member
Joined
Mar 22, 2015
Messages
1,091
Office Version
  1. 2013
Platform
  1. Windows
hi
try to
Code:
Set myRng = Union(Range("a1"), Range("b4")) as an example
 

Watch MrExcel Video

Forum statistics

Threads
1,127,972
Messages
5,627,933
Members
416,282
Latest member
fchagas97

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
Top