ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   tightening up VBA (https://www.excelbanter.com/excel-programming/373738-tightening-up-vba.html)

Arnold Klapheck

tightening up VBA
 
I have been able to go from this:
Columns("F:F").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert shift:=xlToRight

to this:
Columns("F:F").Cut
Columns("A:A").Insert shift:=xlToRigh

But when I try to go to this:
Columns("F:F").Cut Destination:=Range("A:A").Insert.shift:=xlToRight

I get an error, any suggestions?

I am also trying to get this to tighten up:
Columns("F:F").Select
Selection.Style = "Comma"
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"

I tried this but the second line dosn't work:
Columns("F:F").Style = "Comma"
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"

thanks for any help.

Tom Ogilvy

tightening up VBA
 
Columns("F:F").Cut Destination:=Range("A:A")


With Columns("F:F")
.Style = "Comma"
.NumberFormat = _
"_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"
End With

--
Regards,
Tom Ogilvy



"Arnold Klapheck" wrote:

I have been able to go from this:
Columns("F:F").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert shift:=xlToRight

to this:
Columns("F:F").Cut
Columns("A:A").Insert shift:=xlToRigh

But when I try to go to this:
Columns("F:F").Cut Destination:=Range("A:A").Insert.shift:=xlToRight

I get an error, any suggestions?

I am also trying to get this to tighten up:
Columns("F:F").Select
Selection.Style = "Comma"
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"

I tried this but the second line dosn't work:
Columns("F:F").Style = "Comma"
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"

thanks for any help.


Don Guillett

tightening up VBA
 
Columns("J").Cut
Columns("G").Insert Shift:=xlToRight

with Columns("F:F").
..Style = "Comma"
..NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"
end with

--
Don Guillett
SalesAid Software

"Arnold Klapheck" wrote in
message ...
I have been able to go from this:
Columns("F:F").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert shift:=xlToRight

to this:
Columns("F:F").Cut
Columns("A:A").Insert shift:=xlToRigh

But when I try to go to this:
Columns("F:F").Cut Destination:=Range("A:A").Insert.shift:=xlToRight

I get an error, any suggestions?

I am also trying to get this to tighten up:
Columns("F:F").Select
Selection.Style = "Comma"
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(*
""-""??_);_(@_)"

I tried this but the second line dosn't work:
Columns("F:F").Style = "Comma"
Selection.NumberFormat = "_(* #,##0.0_);_(* (#,##0.0);_(*
""-""??_);_(@_)"

thanks for any help.




Arnold Klapheck

tightening up VBA
 
Columns("F:F").Cut Destination:=Range("A:A")
This pastes over the info in the column, I need to shift everything over to
the right.
also I can't select 2 columns to cut and past without selecting two columns
to paste to when I just want to paste the columns into a different spot.

Perhaps their is a totally different way to do this, I am attempting to
rearrange columns in a worksheet and sometimes delete entire columns.

thanks for your help so far, any other ideas?

on the second question it seems I am replacing three lines of code with four
lines of code, will the new way make it run faster?

With Columns("F:F")
.Style = "Comma"
.NumberFormat = _
"_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"
End With



Tom Ogilvy

tightening up VBA
 
Don gave you the correct interpretation:

Columns("F").Cut
Columns("A").Insert Shift:=xlToRight


You can look at it as 4 lines of code, but it is actually two commands
because you are performing two actions. The other lines are qualifiers to
avoid selecting. It is faster because it doesn't select. Lines of code per
se do not necessarily determine the efficiency of the approach.

--
Regards,
Tom Ogilvy




"Arnold Klapheck" wrote:

Columns("F:F").Cut Destination:=Range("A:A")

This pastes over the info in the column, I need to shift everything over to
the right.
also I can't select 2 columns to cut and past without selecting two columns
to paste to when I just want to paste the columns into a different spot.

Perhaps their is a totally different way to do this, I am attempting to
rearrange columns in a worksheet and sometimes delete entire columns.

thanks for your help so far, any other ideas?

on the second question it seems I am replacing three lines of code with four
lines of code, will the new way make it run faster?

With Columns("F:F")
.Style = "Comma"
.NumberFormat = _
"_(* #,##0.0_);_(* (#,##0.0);_(* ""-""??_);_(@_)"
End With



Arnold Klapheck

tightening up VBA
 
Thanks, i appreciate your help.


All times are GMT +1. The time now is 10:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com