3 Actions VBA Copy, Clear contents ("") and Shift all to left

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,</SPAN></SPAN>

Below example columns C:K result are by formulas, all formulas have not an outcome; in that case the formula has leaved a cell blank with (""). </SPAN></SPAN>

Now I need a VBA code that does 3 actions...</SPAN></SPAN>
1-Copy values of columns C:K into M:U</SPAN></SPAN>
2- Clear contents ("") of columns M:U</SPAN></SPAN>
3-Shift all values to left </SPAN></SPAN>


Book1
ABCDEFGHIJKLMNOPQRSTU
1
2
3
4
5n1n2n3n4n5n6n7n8n9n1n2n3n4n5n6n7n8n9
622212221
722122212
822212221
91111311113
1023112311
11211111211111
12232232
132211122111
141111311113
1521312131
161211212112
17232232
1841114111
192121121211
20211111211111
212112121121
222112121121
233111131111
242211122111
256161
2632113211
2721222122
2812221222
291212112121
3032113211
316161
3213211321
33121111121111
3431213121
351221112211
362111221112
3731123112
383111131111
3921222122
401221112211
4131123112
421212112121
432112121121
442211122111
4541114111
4641114111
4741114111
4831123112
4923112311
5041114111
511221112211
5241114111
53211111211111
54211111211111
551113111131
561122111221
57211111211111
5841114111
595252
601212112121
Sheet8


Thank you all</SPAN></SPAN>

Excel 2000</SPAN></SPAN>
Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Does this do what you want...
Code:
[table="width: 500"]
[tr]
	[td]Sub motilulla()
  With Range("C6:K" & Cells.Find("*", , xlValues, , xlRows, xlPrevious, , , False).Row)
    .Offset(, 10).Value = .Value
    .Offset(, 10).SpecialCells(xlBlanks).Delete xlShiftToLeft
  End With
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Hello Rick, code highlight ".Find" and give the message that numbers of arguments are not correct

Thank you

Regards,
Moti

Hi motilulla, did you copy/paste the code or re-write it?
 
Upvote 0
Hello Rick, code highlight ".Find" and give the message that numbers of arguments are not correct

Thank you

Regards,
Moti
Hello Rick, removing 2 coma after the xlPrevious as below the code worked fine </SPAN></SPAN>

Code:
Sub motilulla()
  
  'With Range("C6:K" & Cells.Find("*", , xlValues, , xlRows, xlPrevious,[B][COLOR=#ff0000] , ,[/COLOR][/B] False).Row)
   
   With Range("C6:K" & Cells.Find("*", , xlValues, , xlRows, xlPrevious, False).Row)
    .Offset(, 10).Value = .Value
    .Offset(, 10).SpecialCells(xlBlanks).Delete xlShiftToLeft
   End With
  
End Sub
</SPAN></SPAN>

Thank you for your help</SPAN></SPAN>

Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 
Last edited:
Upvote 0
I think the issue shows up in your signature block in your first post.

Excel 2000
Regards,
Moti

I am pretty sure back then MatchByte didn't exist, not sure what other parameter didn't. Probably SearchFormat at a guess. It's a very old version now and so documentation is scarce.
 
Upvote 0
I think the issue shows up in your signature block in your first post.

Excel 2000
Regards,
Moti

I am pretty sure back then MatchByte didn't exist, not sure what other parameter didn't. Probably SearchFormat at a guess. It's a very old version now and so documentation is scarce.
Hello MARK858, yes it is too old version, but removing the 2 comas Rick code worked fine no problem.</SPAN></SPAN>

But now I come up with new trouble after running the code, in the column V insert the formula =M6&" | "&N6&" | "&O6&" | "&P6&" | "&Q6&" | "&R6&" | "&S6&" | "&T6&" | "&U6, sheet result look like perfect
</SPAN>

Book1
ABCDEFGHIJKLMNOPQRSTUV
1
2
3
4
5n1n2n3n4n5n6n7n8n9n1n2n3n4n5n6n7n8n9Join
6222122212 | 2 | 2 | 1 | | | | |
7221222122 | 2 | 1 | 2 | | | | |
8222122212 | 2 | 2 | 1 | | | | |
911113111131 | 1 | 1 | 1 | 3 | | | |
10231123112 | 3 | 1 | 1 | | | | |
112111112111112 | 1 | 1 | 1 | 1 | 1 | | |
122322322 | 3 | 2 | | | | | |
1322111221112 | 2 | 1 | 1 | 1 | | | |
1411113111131 | 1 | 1 | 1 | 3 | | | |
15213121312 | 1 | 3 | 1 | | | | |
1612112121121 | 2 | 1 | 1 | 2 | | | |
172322322 | 3 | 2 | | | | | |
18411141114 | 1 | 1 | 1 | | | | |
1921211212112 | 1 | 2 | 1 | 1 | | | |
202111112111112 | 1 | 1 | 1 | 1 | 1 | | |
2121121211212 | 1 | 1 | 2 | 1 | | | |
2221121211212 | 1 | 1 | 2 | 1 | | | |
2331111311113 | 1 | 1 | 1 | 1 | | | |
2422111221112 | 2 | 1 | 1 | 1 | | | |
2561616 | 1 | | | | | | |
26321132113 | 2 | 1 | 1 | | | | |
27212221222 | 1 | 2 | 2 | | | | |
28122212221 | 2 | 2 | 2 | | | | |
2912121121211 | 2 | 1 | 2 | 1 | | | |
30321132113 | 2 | 1 | 1 | | | | |
3161616 | 1 | | | | | | |
32132113211 | 3 | 2 | 1 | | | | |
331211111211111 | 2 | 1 | 1 | 1 | 1 | | |
34312131213 | 1 | 2 | 1 | | | | |
3512211122111 | 2 | 2 | 1 | 1 | | | |
3621112211122 | 1 | 1 | 1 | 2 | | | |
37311231123 | 1 | 1 | 2 | | | | |
3831111311113 | 1 | 1 | 1 | 1 | | | |
39212221222 | 1 | 2 | 2 | | | | |
4012211122111 | 2 | 2 | 1 | 1 | | | |
41311231123 | 1 | 1 | 2 | | | | |
4212121121211 | 2 | 1 | 2 | 1 | | | |
4321121211212 | 1 | 1 | 2 | 1 | | | |
4422111221112 | 2 | 1 | 1 | 1 | | | |
45411141114 | 1 | 1 | 1 | | | | |
46411141114 | 1 | 1 | 1 | | | | |
47411141114 | 1 | 1 | 1 | | | | |
48311231123 | 1 | 1 | 2 | | | | |
49231123112 | 3 | 1 | 1 | | | | |
50411141114 | 1 | 1 | 1 | | | | |
5112211122111 | 2 | 2 | 1 | 1 | | | |
52411141114 | 1 | 1 | 1 | | | | |
532111112111112 | 1 | 1 | 1 | 1 | 1 | | |
542111112111112 | 1 | 1 | 1 | 1 | 1 | | |
5511131111311 | 1 | 1 | 3 | 1 | | | |
5611221112211 | 1 | 2 | 2 | 1 | | | |
572111112111112 | 1 | 1 | 1 | 1 | 1 | | |
58411141114 | 1 | 1 | 1 | | | | |
5952525 | 2 | | | | | | |
6012121121211 | 2 | 1 | 2 | 1 | | | |
Sheet8

</SPAN>
When I re rum the code the sheet change as below why the column V shifted to left?


Book1
ABCDEFGHIJKLMNOPQRSTUV
1
2
3
4
5n1n2n3n4n5n6n7n8n9n1n2n3n4n5n6n7n8n9Join
622212221#REF!
722122212#REF!
822212221#REF!
91111311113#REF!
1023112311#REF!
11211111211111#REF!
12232232#REF!
132211122111#REF!
141111311113#REF!
1521312131#REF!
161211212112#REF!
17232232#REF!
1841114111#REF!
192121121211#REF!
20211111211111#REF!
212112121121#REF!
222112121121#REF!
233111131111#REF!
242211122111#REF!
256161#REF!
2632113211#REF!
2721222122#REF!
2812221222#REF!
291212112121#REF!
3032113211#REF!
316161#REF!
3213211321#REF!
33121111121111#REF!
3431213121#REF!
351221112211#REF!
362111221112#REF!
3731123112#REF!
383111131111#REF!
3921222122#REF!
401221112211#REF!
4131123112#REF!
421212112121#REF!
432112121121#REF!
442211122111#REF!
4541114111#REF!
4641114111#REF!
4741114111#REF!
4831123112#REF!
4923112311#REF!
5041114111#REF!
511221112211#REF!
5241114111#REF!
53211111211111#REF!
54211111211111#REF!
551113111131#REF!
561122111221#REF!
57211111211111#REF!
5841114111#REF!
595252#REF!
601212112121#REF!
Sheet9


Does it can be solved? </SPAN></SPAN>

Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 
Upvote 0
If you Delete/Shift cells to the left then everything to the right shifts. The easiest way around it would be to clear column V at the start of the macro then insert the formula with code at the end of the macro.
 
Upvote 0
If you Delete/Shift cells to the left then everything to the right shifts. The easiest way around it would be to clear column V at the start of the macro then insert the formula with code at the end of the macro.
Thank you MARK858, for the suggestion got it that could be the possible solution. </SPAN></SPAN>

Would be any formula solution that can be use in the column M:U which can group the values ? </SPAN></SPAN>

Regards,</SPAN></SPAN>
Moti</SPAN></SPAN>
 
Upvote 0

Forum statistics

Threads
1,224,927
Messages
6,181,799
Members
453,067
Latest member
cernytomas

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