Solved

Declaring variables

Posted on 2013-12-10
6
138 Views
Last Modified: 2013-12-10
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
Comment
Question by:Stephen Byrom
6 Comments
 
LVL 13

Assisted Solution

by:Alexander Eßer [Alex140181]
Alexander Eßer [Alex140181] earned 50 total points
ID: 39708672
Do you mind sharing the Excel file or maybe a part of it?!
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39708693
It looks ok to me. Which line are you getting the error?
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 350 total points
ID: 39708710
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 100 total points
ID: 39708737
Good catch rorya but that would not give the "Application...." error. Unless the error is wrongly reported here.
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 39708762
I know - hence my follow-up questions. :)
0
 
LVL 1

Author Closing Comment

by:Stephen Byrom
ID: 39709507
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Moving Excel to AaaS 4 37
Want to create a userform that looks like the image provided 10 44
Automating Excel Weekly Report 13 61
Help with Excel formula 6 38
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now