delecting specific cells Vba code

papare

New Member
Joined
Nov 24, 2013
Messages
26
I am using the below code but cannt understand the error (bold code). The main of the code is to select a range of cells data, paste it on SD (sheet) acts a database and then reset all the relevant cells/delect/clear. Kindly assist

Sub uploadsinf()
Application.ScreenUpdating = False
Dim bottomV As Long
bottomH = Sheets("SD").Range("L" & Rows.Count).End(xlUp).Row
Sheets("Info").Range("D25:D46").Copy
Sheets("SD").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial _
Paste:=xlPasteValues, Transpose:=True
Sheets("Info").Range("D8,D10,D12,D15,D16,D17,F6,F8,F10,F12,F15,F16,F17,J6,J8,J10,M8").ClearContents
Application.CutCopyMode = False
Sheets("SD").Select
Sheets("SD").Range("A2:V" & bottomV).Select
Sheets("SD").Sort.SortFields.Clear
Sheets("SD").Sort.SortFields.Add Key:=Range("A2:A" & bottomH), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With Sheets("SD").Sort
.SetRange Range("A1:V" & bottomV)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.ScreenUpdating = True
Sheets("Info").Select
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

papare

New Member
Joined
Nov 24, 2013
Messages
26
the code just breaks at Sheets("Info").Range("D8,D10,D12,D15,D16,D17,F6,F8,F10,F12,F15,F16,F17,J6,J8,J10,M8").ClearContents
 
Upvote 0

papare

New Member
Joined
Nov 24, 2013
Messages
26
no message, the code just breaks
code break.png
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
Certainly the error message should shed some light on the problem. Still, a couple of possible culprits come to mind ..

1. Sheets 'Info' could be protected,

2. That range on 'Info' that is to be cleared could include some merged cells.
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
no message, the code just breaks
code break.png
You cannot display images stored on your computer. You would need to upload them to a file-sharing site and provide a link to the image.
 
Upvote 0

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
59,294
Office Version
  1. 365
Platform
  1. Windows
Dear papare,

bottomH not declared & bottomV not defined.

Regards,
Nandkumar S.
.. but neither of those would cause an error in the line bolded?

In fact, if the code is getting to the bold line then 'Option Explicit' must not be in force which means neither of those issues would cause any error in any case.
 
Upvote 0

papare

New Member
Joined
Nov 24, 2013
Messages
26
Thanks, it was a merger of a cell which was causing the problem and thanks for the heads up with the bootomH & bottomV
 
Upvote 0

Forum statistics

Threads
1,191,005
Messages
5,984,120
Members
439,872
Latest member
noaman79

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