Solved

Declaring variables

Posted on 2013-12-10
6
146 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

730 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