Home > Blockchain >  VBA Convert Negative Numbers to Postive
VBA Convert Negative Numbers to Postive

Time:02-04

after the function that filters my results below zero, I have to write it as a positive result, i.e. without "-". However, I get the error "Object variable or With block not set" . What I doing wrong ?

Dim cl As Range
cl = wbMe.Sheets("pochodne").Range("T35").Copy
   If cl.Value < 0 Then
       cl.Value = -cl.Value
   End If

CodePudding user response:

Objects need to be "set", so try:

Dim wbMe    As Excel.Workbook
Dim cl      As Excel.Range

Set wbMe = ThisWorkbook

Set cl = wbMe.Worksheets("pochodne").Range("T35")
If cl.Value < 0 Then
   cl.Value = -cl.Value
End If

That works here.

  •  Tags:  
  • Related