• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How can I Get my Macro to only go to Column N

I have a Macro that goes to column "O" and I want to change it to only go to column "N". What needs to change? I thought it was the letter i but I can not find my notes what letters = what. Thanks for the help

Code:
Sub ResetBackToGame()
  Dim d As Double:
  d = Application.WorksheetFunction.CountIf([i2:i101], "?")
  Dim i As Integer:
  'make sure user entered positive number 1 to 50 into Q5
  If IsEmpty(Range("Q5")) _
  Or Range("Q5") < 1 _
  Or Range("Q5") > 50 Then
    'do nothing if is empty or value not between 1 and 50, inclusive
    Exit Sub
  End If
  i = 50 - [q5]
  Application.ScreenUpdating = False
  [I2:O101].Copy Cells(3 + i - d, 9)    'copies I2:O101 to position (3+i-d) rows down.
  Range("i2", Cells(2 + i, 15)) = "?"  'puts ? in I2 over & down to cleared row in O.
  [i102:o152].CLEAR: [q5].ClearContents
  Application.ScreenUpdating = True    'not required, auto-resets to True at End Sub or Exit Sub
End Sub

If you need a copy of the book I can upload one. In the snip you will see the ? in column "O". The macro tells it to place an ? in a blank cell but I do not want it to look at "O" only go to "N"

Thanks
 

Attachments

  • reset.jpg
    reset.jpg
    149.8 KB · Views: 2
Last edited:
Hi:

try changing
Code:
Range("i2", Cells(2 + i, 15)) = "?"
to
Code:
Range("i2", Cells(2 + i, 14)) = "?"

Thanks
 
Hi:

The numbers are the column references,

Cells(row,column)=>Cells(2,15), means 2nd row and 15th column

Thanks
 
should I change this as well. My Macro stops here and when I go to debug this is in yellow

Code:
  [I2:O101].Copy Cells(3 + i - d, 9)    'copies I2:O101 to position (3+i-d) rows down.
 
Hi:

Could you clearly explain what you want to achieve here. I tried running the macro you had. [I2:O101].Copy Cells(3 + i - d, 9) what does this line suppose to do , The comments in the macro says that this line should copy [I2:O101] to (3 + i - d, 9)th position, but it only copies range[I2:O101] where is the code to paste the same to (3 + i - d, 9)th position, or am I missing something.

Thanks
 
Hi:

Could you clearly explain what you want to achieve here. I tried running the macro you had. [I2:O101].Copy Cells(3 + i - d, 9) what does this line suppose to do , The comments in the macro says that this line should copy [I2:O101] to (3 + i - d, 9)th position, but it only copies range[I2:O101] where is the code to paste the same to (3 + i - d, 9)th position, or am I missing something.

Thanks
I don't think your missing anything. I'm trying to write code and I'm struggling. Between youtube and forums is how I'm trying to learn Ninjas like you are so SO helpful in my journey. Thank you

How I want it to work. When I put a Game number in Q5 the macro is suppose to copy what is presently in I2:N101 and move everything down and paste them to the game number I place in Q5 putting ? In the cells with no data

All those Game sheets #40-50 get data from xternal sheets that is driven off the Input sheet which us the one were working on. Once I get this Macro fixed everything else follows suit.

Can you aid in the paste portion? Thank you for your help
 
Hi:

I have written codes as per my understanding I am not sure whether is is what you are looking for...

Thanks
 

Attachments

  • sample.xlsb
    606.7 KB · Views: 4
Hi:

I have written codes as per my understanding I am not sure whether is is what you are looking for...

Thanks


Your code does reset the Game numbers down to the row Gae number I place in Q5 but it does not clear off the data in the rows in the eternal sheets. Presently once a group of numbers say all numbers in row 2 are removed it automatically removes all other data in the other sheets. So If row 2 numbers are removed Game 50 numbers should go away.
 
Back
Top