VBA Question/Help

ststern45

Well-known Member
Joined
Sep 17, 2005
Messages
958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I have the following code and want to change the location of the calculations.

I'm not sure how the cell row column etc. works but here goes:

I current have the calculations in 1 worksheet in cell column A1:A1000 and the calculations that remove the blank cells is in column B1:B1000.
I want to change it in cell range AF1:AF1000 and the calculations in cell range AK1:AK1000

Would I need to change the Cells(i, 1) another value to match cell column AF?

Thanks in advance!!


Code:
Sub DeleteBlankRows()

Dim counter As Integer, i As Integer

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
counter = 0

For i = 1 To 1000
    If Cells(i, 1).Value <> "" Then
        Cells(counter + 1, 2).Value = Cells(i, 1).Value
        counter = counter + 1
    End If
Next i

Range("F1").Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


End Sub
 
Last edited by a moderator:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi ststern45,

You can just change to the column text...

Code:
Sub DeleteBlankRows()

Dim counter As Integer, i As Integer

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
counter = 0

For i = 1 To 1000
    If Cells(i, [COLOR="#FF0000"]"AF"[/COLOR]).Value <> "" Then
        Cells(counter + 1, [COLOR="#FF0000"]"AK"[/COLOR]).Value = Cells(i, [COLOR="#FF0000"]"AF"[/COLOR]).Value
        counter = counter + 1
    End If
Next i

Range("F1").Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


End Sub

Hope this helps,
Cheers,
Alan.
 
Last edited:
Upvote 0
Just a followup question

Ho do I change the code to range AF20:AF1019 and AK20:AK1019

Thanks in advance!!

Sub DeleteBlankRows()

Dim counter As Integer, i As Integer

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
counter = 0

For i = 1 To 1000
If Cells(i, "AF").Value <> "" Then
Cells(counter + 1, "AK").Value = Cells(i, "AF").Value
counter = counter + 1
End If
Next i

Range("F1").Select
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


End Sub
 
Upvote 0
Do you mean...
Rich (BB code):
For i = 1 To 1000

TO

For i = 20 To 1019
 
Upvote 0

Forum statistics

Threads
1,213,544
Messages
6,114,249
Members
448,556
Latest member
peterhess2002

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