Solved

Declaring variables

Posted on 2013-12-10
6
135 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
Comment Utility
Do you mind sharing the Excel file or maybe a part of it?!
0
 
LVL 43

Expert Comment

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

Accepted Solution

by:
Rory Archibald earned 350 total points
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 100 total points
Comment Utility
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
Comment Utility
I know - hence my follow-up questions. :)
0
 
LVL 1

Author Closing Comment

by:Stephen Byrom
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

762 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

10 Experts available now in Live!

Get 1:1 Help Now