VBA to select values

KenC53

New Member
Joined
Jul 24, 2011
Messages
14
I have a macro (Sub SelectData) that selects a range going down from A2 to the last row with values and the over right to the last column with values. The code selects all cells with formulas, even those returning no value leaving the cell blank. how do I change the macro to slect only the cells that have values returned and not those with only formulas entered. The last cell in column A with values is row A96 but this macro selects down to row 150 because there are formulas but no values present. Here is the macro:

ActiveSheet.Range("A2:" & ActiveSheet.Range("A2").End(xlDown). _
End(xlToRight).Address).Select

Ken
<!-- / message --><!-- BEGIN TEMPLATE: ad_showthread_firstpost_sig --><!-- END TEMPLATE: ad_showthread_firstpost_sig -->
 
I forgot to add, Column A will always have a value until the first cell in column A that returns a "", after that there will not be an entry in column A.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
This returns only one row of data copied. It copies as a link to the data. Is it possible to paste the values instead of the links?

Application.ScreenUpdating = False
Dim cell As Range
For Each cell In Columns(1).SpecialCells(3)
If Len(cell.Value) > 0 Then
Range(Cells(cell.Row, 1), Cells(cell.Row, 9)).Copy
Windows("Test.xlsx").Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Next cell
Application.ScreenUpdating = True
 
Upvote 0
Actually I realized I missed a line. It is working better. Columns A:E are text that is being returned from a cell on another sheet. These are not being copied and pasted correctly with this code. The data in columns F:I is copying and pasting correctly.


Application.ScreenUpdating = False
Dim cell As Range
For Each cell In Columns(1).SpecialCells(3)
If Len(cell.Value) > 0 Then
Range(Cells(cell.Row, 1), Cells(cell.Row, 9)).Copy
Windows("Test.xlsx").Activate
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False
End If
Application.CutCopyMode = False
Next cell
Application.ScreenUpdating = True
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,233
Members
453,152
Latest member
ChrisMd

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