[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 157
  • Last Modified:

Declaring variables

I'm having trouble with my declarations I think.
I can never decide if it should be a Long or Range or Cell etc etc.

I am struggling to get the attached code working as I keep getting "application defined or object defined error", which I presume means I got it wrong again regarding my declarations.  

As always any pointers are greatly appreciated, and maybe someone could point me in the right direction of any articles helping me understand Excel VBA declarations.

Thanks
Dim x As Range
Dim ws As Worksheet
Dim lr As Long
Set ws = ThisWorkbook.Sheets("Data")

lr = ws.Range("T1048576").End(xlUp).Row
    For Each x In ws.Range("T3:T" & lr).Cells
        If x.Value <> 0 Then
            ws.Range("AL1048576").End(xlUp).Offset(1).vlaue = x.Offset(1).Value
        End If
    Next x

Open in new window


I have tried a number of variations of the Range,Cell,Long etc etc to no avail.
0
Stephen Byrom
Asked:
Stephen Byrom
3 Solutions
 
Alexander Eßer [Alex140181]Software DeveloperCommented:
Do you mind sharing the Excel file or maybe a part of it?!
0
 
Saqib Husain, SyedEngineerCommented:
It looks ok to me. Which line are you getting the error?
0
 
Rory ArchibaldCommented:
You have misspelled Value here:
ws.Range("AL1048576").End(xlUp).Offset(1).vlaue

Is this your actual code? If not, can you copy and paste the actual code here?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Saqib Husain, SyedEngineerCommented:
Good catch rorya but that would not give the "Application...." error. Unless the error is wrongly reported here.
0
 
Rory ArchibaldCommented:
I know - hence my follow-up questions. :)
0
 
Stephen ByromAuthor Commented:
Sorry, I had to step out for a while......

I've been developing this workbook for some time now and I am starting to miss the obvious. Thanks rorya, and thanks to the rest for taking the time to comment.

regarding attaching the workbook for better clarity;
I have the slowest of connection speeds :( and attaching the file would have probably taken a week. (rural Ireland is not hot on technology) :)
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now