JaccoVis90

New Member
Joined
Oct 30, 2015
Messages
34
Hey all,

I have a question about my VBA project

I copied in a large Range ("Lamp") = GO200:TY340 multiple times with an offset each time. All goes fine here. But every next line that uses a kind of selection returns to an error. (so wsb.Range("A1").select = errorline)

If i remove this line then the errorline goed to: wsb.Range("A2:A3").AutoFill Destination:=Range("A2:A98"), Type:=xlFillDefault

I can solve this error to pause the macro, scoll up/down in the sheet en continu the VBA. You can visualy see that the selection is in a L shape en returns to a square after scrolling in the window. Is there a way to fix it?

i try to use .select minimal

Dim en sets are correct

Code:
berekening.Range("Lamp").Copy
wsb.Range("B2").PasteSpecial (xlPasteValuesAndNumberFormats)
berekening.Range("Lamp").Offset(0, Hschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
berekening.Range("Lamp").Offset(0, -Hschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
berekening.Range("Lamp").Offset(0, Hschuif + Hschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
berekening.Range("Lamp").Offset(0, -Hschuif - Hschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
berekening.Range("Lamp").Offset(-Vschuif, HVSschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
berekening.Range("Lamp").Offset(-Vschuif, -HVSschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
berekening.Range("Lamp").Offset(-Vschuif, Hschuif + HVSschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
berekening.Range("Lamp").Offset(-Vschuif, -HVSschuif - Hschuif).Copy
wsb.Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd


wsb.Range("A1").Select
Application.CutCopyMode = False






Set Slack = wsb.Range("B2:QC195")




Application.ScreenUpdating = False
    wsb.Columns("B:QD").ColumnWidth = 2.14
    
    Slack.FormatConditions.AddColorScale ColorScaleType:=2
    Slack.FormatConditions(1).ColorScaleCriteria(1).Type = _
        xlConditionValueNumber
    Slack.FormatConditions(1).ColorScaleCriteria(1).Value = 0
    With Slack.FormatConditions(1).ColorScaleCriteria(1).FormatColor
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.149998474074526
    End With
    Slack.FormatConditions(1).ColorScaleCriteria(2).Type = _
        xlConditionValueNumber
    Slack.FormatConditions(1).ColorScaleCriteria(2).Value = 200
    With Slack.FormatConditions(1).ColorScaleCriteria(2).FormatColor
        .Color = 65535
        .TintAndShade = 0
    End With
    
    With Selection.Font
        .Name = "Calibri"
        .Size = 11
    End With
    Slack.NumberFormat = "0"
    
    Application.ScreenUpdating = True
    
    wsb.Range("A2").Value = -120
    wsb.Range("A3").Value = -115
    wsb.Range("B1").Value = -870
    wsb.Range("C1").Value = -865
        
    wsb.Range("A2:A3").AutoFill Destination:=Range("A2:A98"), Type:=xlFillDefault
    wsb.Range("B1:C1").AutoFill Destination:=Range("B1:ML1"), Type:=xlFillDefault
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You can only select a cell on the activesheet. That will not error if wsb is the activesheet and will error if it isnt.
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

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