blowing my mind

dialup

Board Regular
Joined
Jan 10, 2008
Messages
99
Hello all

I am not very knowledgable in vba and have been desperatly trying to ammend macros to do what i need with no success.
i have a sheet with lots of columns
i need a macro to copy what you see in column AS into column AT from the row2 to the last populated row on the sheet.
column AS is a date formated to show the day only - i need AT to show the word not the formula so vba copying the text in AS to AT works - i just cant get it to find the last populated cell in column A and run from row 2 to that row.
Can anyone please help?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Code:
Sub Fanugi()
Dim LR As Integer
Dim cl As Range
LR = Range("$A" & Rows.Count).Row
For Each cl In Range(Cells(2, 1), Cells(LR, 1))
     'Your code
Next cl
    
End Sub

lenze
 
Upvote 0
thanks for the quick response

I tried this code but get Run-time error 6 : overflow

I am using 2003
 
Upvote 0
Should probably use Long instead of Integer for LR

Dim LR As Long


I would guess your data is pretty large..Integer is limited to 32,767
So if you have 32,768 or more rows, then it would overflow..
 
Upvote 0
Also

This

LR = Range("$A" & Rows.Count).Row

was probably meant to be

LR = Range("$A" & Rows.Count).End(xlUp).Row
 
Upvote 0
ok so my code looks like
Code:
Sub Fanugi()
Application.ScreenUpdating = False
Dim LR As Long

Dim cl As Range
With Worksheets("Master")
LR = Range("$A" & Rows.count).End(xlUp).Row
For Each cl In Range(Cells(2, 1), Cells(LR, 1))
Worksheets("Master").Range("at" & Rows.count) = Worksheets("Master").Range("as" & Rows.count).Text
Next cl
    End With
End Sub

when i run the macro the egg timer comes up but column AT is still empty
 
Upvote 0
Try

Code:
Sub Fanugi()
Application.ScreenUpdating = False
Dim LR As Long
Dim cl As Range

With Worksheets("Master")
    LR = .Range("AS" & Rows.count).End(xlUp).Row
    For Each cl In .Range(.Cells(2, 1), .Cells(LR, 1))
        cl.Offset(0,1).Value = cl.Text
    Next cl
End With
Application.ScreenUpdating = True
End Sub
 
Upvote 0
still no joy - column AS is populated with a date formatted to show the day - i have even replaced cl.text with "bob" just to see if the column was populated with the word but it wasnt??

so i created a new spreadsheet, filled column a with hello, changed the column reference in the macro to A, ran the macro and it works fine. so the issue must be with my spreadsheet.
 
Last edited:
Upvote 0
OK, macro was previously written to read dates from column A, not column AS

For Each cl in .Range(.Cells(2,1),.Cells(LR,1))

That should be

For Each cl in .Range(.Cells(2,"AS"),.Cells(LR,"AS"))
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,704
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top