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
 
Thanks, it was a merger of a cell which was causing the problem
Glad you tracked it down, but doesn't that mean you were previously getting a message like this when you ran the code?

Run-time error '1004':
Cannot change part of a merged cell.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
but doesn't that mean you were previously getting a message like this when you ran the code?

Run-time error '1004':
Cannot change part of a merged cell.
Yes i was..
That's what Chris Mack was asking about in posts #2 & 4 but you responded then with "no message, the code just breaks" ;)
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
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