Macro does not do all the functions it’s suppose to do












0















Apologies if this is a simple question but I have a macro that divides as it should but it will not copy and paste the contents from one cell to another cell as it’s suppose to do. See below for examples with expected result.



Sub master2()
Application.ScreenUpdating = False

Dim pair As Variant, accumulator As Variant
Dim findFifteen As Double
Dim remainder As Long, found As Long

found = 1

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = 15 Then
If pair.Offset(0, 2) <= 12 Then
findFifteen = pair.Offset(0, 2) / 12
remainder = 0
Else
findFifteen = 1
remainder = pair.Offset(0, 2) Mod 12
End If

For Each accumulator In Range("A14, B14, C14, D14, E14, F14, G14, H14, I14, J14, K14, L14")
If accumulator.Offset(-1, 0) = Val(Left(pair, InStr(pair, "-") - 1)) Then
accumulator.Value = accumulator.Value + remainder
End If
accumulator.Value = accumulator.Value + findFifteen
Next accumulator

Range("E" & found).Value = pair
found = found + 1
End If
Next pair

Application.ScreenUpdating = True
End Sub


Example with expected result.



As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1). Do the same with all cells: B30, F30 and J30 but only if they contain a 15 (1-15 or 7-15 etc.) as the last number. After this delete all contents in cell B30, C30, D30. There are are two examples in my Excel sheet where the same thing needs to happen.



excel image










share|improve this question

























  • Have you stepped through? Is this right If accumulator.Offset(-1, 0) = as the offset is row 13 which is full of letters?

    – SJR
    Nov 13 '18 at 19:09






  • 1





    On closer examination, your description doesn't seem to tally with your code.

    – SJR
    Nov 13 '18 at 19:13











  • The macro works except for the end where it's suppose to move the contents form cells B30, F30 and J30. Which part of my description is not correct?

    – NANCY SKYES
    Nov 13 '18 at 19:22











  • Hi, I just did the step through and it finds the cell where the contents of either cells B30, F30 and J30 are to be moved to and then it does nothing. Thanks o much for your help.

    – NANCY SKYES
    Nov 13 '18 at 20:22











  • Which line is it that you don't think is working? I can't see where you are adding 1 to the last digits. Sorry but I'm confused.

    – SJR
    Nov 13 '18 at 20:43
















0















Apologies if this is a simple question but I have a macro that divides as it should but it will not copy and paste the contents from one cell to another cell as it’s suppose to do. See below for examples with expected result.



Sub master2()
Application.ScreenUpdating = False

Dim pair As Variant, accumulator As Variant
Dim findFifteen As Double
Dim remainder As Long, found As Long

found = 1

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = 15 Then
If pair.Offset(0, 2) <= 12 Then
findFifteen = pair.Offset(0, 2) / 12
remainder = 0
Else
findFifteen = 1
remainder = pair.Offset(0, 2) Mod 12
End If

For Each accumulator In Range("A14, B14, C14, D14, E14, F14, G14, H14, I14, J14, K14, L14")
If accumulator.Offset(-1, 0) = Val(Left(pair, InStr(pair, "-") - 1)) Then
accumulator.Value = accumulator.Value + remainder
End If
accumulator.Value = accumulator.Value + findFifteen
Next accumulator

Range("E" & found).Value = pair
found = found + 1
End If
Next pair

Application.ScreenUpdating = True
End Sub


Example with expected result.



As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1). Do the same with all cells: B30, F30 and J30 but only if they contain a 15 (1-15 or 7-15 etc.) as the last number. After this delete all contents in cell B30, C30, D30. There are are two examples in my Excel sheet where the same thing needs to happen.



excel image










share|improve this question

























  • Have you stepped through? Is this right If accumulator.Offset(-1, 0) = as the offset is row 13 which is full of letters?

    – SJR
    Nov 13 '18 at 19:09






  • 1





    On closer examination, your description doesn't seem to tally with your code.

    – SJR
    Nov 13 '18 at 19:13











  • The macro works except for the end where it's suppose to move the contents form cells B30, F30 and J30. Which part of my description is not correct?

    – NANCY SKYES
    Nov 13 '18 at 19:22











  • Hi, I just did the step through and it finds the cell where the contents of either cells B30, F30 and J30 are to be moved to and then it does nothing. Thanks o much for your help.

    – NANCY SKYES
    Nov 13 '18 at 20:22











  • Which line is it that you don't think is working? I can't see where you are adding 1 to the last digits. Sorry but I'm confused.

    – SJR
    Nov 13 '18 at 20:43














0












0








0








Apologies if this is a simple question but I have a macro that divides as it should but it will not copy and paste the contents from one cell to another cell as it’s suppose to do. See below for examples with expected result.



Sub master2()
Application.ScreenUpdating = False

Dim pair As Variant, accumulator As Variant
Dim findFifteen As Double
Dim remainder As Long, found As Long

found = 1

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = 15 Then
If pair.Offset(0, 2) <= 12 Then
findFifteen = pair.Offset(0, 2) / 12
remainder = 0
Else
findFifteen = 1
remainder = pair.Offset(0, 2) Mod 12
End If

For Each accumulator In Range("A14, B14, C14, D14, E14, F14, G14, H14, I14, J14, K14, L14")
If accumulator.Offset(-1, 0) = Val(Left(pair, InStr(pair, "-") - 1)) Then
accumulator.Value = accumulator.Value + remainder
End If
accumulator.Value = accumulator.Value + findFifteen
Next accumulator

Range("E" & found).Value = pair
found = found + 1
End If
Next pair

Application.ScreenUpdating = True
End Sub


Example with expected result.



As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1). Do the same with all cells: B30, F30 and J30 but only if they contain a 15 (1-15 or 7-15 etc.) as the last number. After this delete all contents in cell B30, C30, D30. There are are two examples in my Excel sheet where the same thing needs to happen.



excel image










share|improve this question
















Apologies if this is a simple question but I have a macro that divides as it should but it will not copy and paste the contents from one cell to another cell as it’s suppose to do. See below for examples with expected result.



Sub master2()
Application.ScreenUpdating = False

Dim pair As Variant, accumulator As Variant
Dim findFifteen As Double
Dim remainder As Long, found As Long

found = 1

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = 15 Then
If pair.Offset(0, 2) <= 12 Then
findFifteen = pair.Offset(0, 2) / 12
remainder = 0
Else
findFifteen = 1
remainder = pair.Offset(0, 2) Mod 12
End If

For Each accumulator In Range("A14, B14, C14, D14, E14, F14, G14, H14, I14, J14, K14, L14")
If accumulator.Offset(-1, 0) = Val(Left(pair, InStr(pair, "-") - 1)) Then
accumulator.Value = accumulator.Value + remainder
End If
accumulator.Value = accumulator.Value + findFifteen
Next accumulator

Range("E" & found).Value = pair
found = found + 1
End If
Next pair

Application.ScreenUpdating = True
End Sub


Example with expected result.



As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1). Do the same with all cells: B30, F30 and J30 but only if they contain a 15 (1-15 or 7-15 etc.) as the last number. After this delete all contents in cell B30, C30, D30. There are are two examples in my Excel sheet where the same thing needs to happen.



excel image







excel vba excel-vba copy-paste






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:00









Pᴇʜ

21.7k42750




21.7k42750










asked Nov 13 '18 at 18:55









NANCY SKYESNANCY SKYES

14




14













  • Have you stepped through? Is this right If accumulator.Offset(-1, 0) = as the offset is row 13 which is full of letters?

    – SJR
    Nov 13 '18 at 19:09






  • 1





    On closer examination, your description doesn't seem to tally with your code.

    – SJR
    Nov 13 '18 at 19:13











  • The macro works except for the end where it's suppose to move the contents form cells B30, F30 and J30. Which part of my description is not correct?

    – NANCY SKYES
    Nov 13 '18 at 19:22











  • Hi, I just did the step through and it finds the cell where the contents of either cells B30, F30 and J30 are to be moved to and then it does nothing. Thanks o much for your help.

    – NANCY SKYES
    Nov 13 '18 at 20:22











  • Which line is it that you don't think is working? I can't see where you are adding 1 to the last digits. Sorry but I'm confused.

    – SJR
    Nov 13 '18 at 20:43



















  • Have you stepped through? Is this right If accumulator.Offset(-1, 0) = as the offset is row 13 which is full of letters?

    – SJR
    Nov 13 '18 at 19:09






  • 1





    On closer examination, your description doesn't seem to tally with your code.

    – SJR
    Nov 13 '18 at 19:13











  • The macro works except for the end where it's suppose to move the contents form cells B30, F30 and J30. Which part of my description is not correct?

    – NANCY SKYES
    Nov 13 '18 at 19:22











  • Hi, I just did the step through and it finds the cell where the contents of either cells B30, F30 and J30 are to be moved to and then it does nothing. Thanks o much for your help.

    – NANCY SKYES
    Nov 13 '18 at 20:22











  • Which line is it that you don't think is working? I can't see where you are adding 1 to the last digits. Sorry but I'm confused.

    – SJR
    Nov 13 '18 at 20:43

















Have you stepped through? Is this right If accumulator.Offset(-1, 0) = as the offset is row 13 which is full of letters?

– SJR
Nov 13 '18 at 19:09





Have you stepped through? Is this right If accumulator.Offset(-1, 0) = as the offset is row 13 which is full of letters?

– SJR
Nov 13 '18 at 19:09




1




1





On closer examination, your description doesn't seem to tally with your code.

– SJR
Nov 13 '18 at 19:13





On closer examination, your description doesn't seem to tally with your code.

– SJR
Nov 13 '18 at 19:13













The macro works except for the end where it's suppose to move the contents form cells B30, F30 and J30. Which part of my description is not correct?

– NANCY SKYES
Nov 13 '18 at 19:22





The macro works except for the end where it's suppose to move the contents form cells B30, F30 and J30. Which part of my description is not correct?

– NANCY SKYES
Nov 13 '18 at 19:22













Hi, I just did the step through and it finds the cell where the contents of either cells B30, F30 and J30 are to be moved to and then it does nothing. Thanks o much for your help.

– NANCY SKYES
Nov 13 '18 at 20:22





Hi, I just did the step through and it finds the cell where the contents of either cells B30, F30 and J30 are to be moved to and then it does nothing. Thanks o much for your help.

– NANCY SKYES
Nov 13 '18 at 20:22













Which line is it that you don't think is working? I can't see where you are adding 1 to the last digits. Sorry but I'm confused.

– SJR
Nov 13 '18 at 20:43





Which line is it that you don't think is working? I can't see where you are adding 1 to the last digits. Sorry but I'm confused.

– SJR
Nov 13 '18 at 20:43












1 Answer
1






active

oldest

votes


















0














As I said, I can't follow what you're doing, but this will give you "7-16" in E1 if B30 contains 7-15 (and similarly for the other cells). I've stripped out most of your code so I don't know if this is a full answer



Sub master2()

Dim pair As Range, found As Variant, v As Variant

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = "15" Then
v = Split(pair, "-")
found = Application.Match(pair.Offset(1),Range("E1:E12"), 0)
If IsNumeric(found) Then
Range("F1:F12").Cells(found).Value = v(0) & "-" & v(1) + 1
End If
End If
Next pair

End Sub





share|improve this answer


























  • I tested your code and it works but I need the rest of the code to make it all work. The great news is I think you may have helped me to solve the problem on my own. If you can bear with me and if I can ask for, I hope, a small amount of help we might be done here. In my original code the line “Range("E" & found).Value = pair” can we change that E (I assume that’s the search criteria) to search specific cells E1 to E12 or use the range E1:E12. I’ve tried to make the change but it will not work. Also, after each copy and paste of cell B30 etc. delete all contents in cell B30, C30, D30 etc.

    – NANCY SKYES
    Nov 14 '18 at 14:09











  • Yes, but where in column E should it go?

    – SJR
    Nov 14 '18 at 15:48











  • I'm getting there using VBA but I have a ways to go so please bear with me. So if I'm correct in saying that it searches column E for the correct cell i would say the range is E1:E12 or am I misunderstanding your question?

    – NANCY SKYES
    Nov 14 '18 at 16:27











  • In the code above, when found=1 the value in B30 is put in E1, and then F30 goes in E2 etc. What I'm asking is what determines the output cell? What are you searching E1:E12 for?

    – SJR
    Nov 14 '18 at 16:35











  • Sorry now I know what you're referring to. As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1).

    – NANCY SKYES
    Nov 14 '18 at 16:38











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287765%2fmacro-does-not-do-all-the-functions-it-s-suppose-to-do%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














As I said, I can't follow what you're doing, but this will give you "7-16" in E1 if B30 contains 7-15 (and similarly for the other cells). I've stripped out most of your code so I don't know if this is a full answer



Sub master2()

Dim pair As Range, found As Variant, v As Variant

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = "15" Then
v = Split(pair, "-")
found = Application.Match(pair.Offset(1),Range("E1:E12"), 0)
If IsNumeric(found) Then
Range("F1:F12").Cells(found).Value = v(0) & "-" & v(1) + 1
End If
End If
Next pair

End Sub





share|improve this answer


























  • I tested your code and it works but I need the rest of the code to make it all work. The great news is I think you may have helped me to solve the problem on my own. If you can bear with me and if I can ask for, I hope, a small amount of help we might be done here. In my original code the line “Range("E" & found).Value = pair” can we change that E (I assume that’s the search criteria) to search specific cells E1 to E12 or use the range E1:E12. I’ve tried to make the change but it will not work. Also, after each copy and paste of cell B30 etc. delete all contents in cell B30, C30, D30 etc.

    – NANCY SKYES
    Nov 14 '18 at 14:09











  • Yes, but where in column E should it go?

    – SJR
    Nov 14 '18 at 15:48











  • I'm getting there using VBA but I have a ways to go so please bear with me. So if I'm correct in saying that it searches column E for the correct cell i would say the range is E1:E12 or am I misunderstanding your question?

    – NANCY SKYES
    Nov 14 '18 at 16:27











  • In the code above, when found=1 the value in B30 is put in E1, and then F30 goes in E2 etc. What I'm asking is what determines the output cell? What are you searching E1:E12 for?

    – SJR
    Nov 14 '18 at 16:35











  • Sorry now I know what you're referring to. As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1).

    – NANCY SKYES
    Nov 14 '18 at 16:38
















0














As I said, I can't follow what you're doing, but this will give you "7-16" in E1 if B30 contains 7-15 (and similarly for the other cells). I've stripped out most of your code so I don't know if this is a full answer



Sub master2()

Dim pair As Range, found As Variant, v As Variant

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = "15" Then
v = Split(pair, "-")
found = Application.Match(pair.Offset(1),Range("E1:E12"), 0)
If IsNumeric(found) Then
Range("F1:F12").Cells(found).Value = v(0) & "-" & v(1) + 1
End If
End If
Next pair

End Sub





share|improve this answer


























  • I tested your code and it works but I need the rest of the code to make it all work. The great news is I think you may have helped me to solve the problem on my own. If you can bear with me and if I can ask for, I hope, a small amount of help we might be done here. In my original code the line “Range("E" & found).Value = pair” can we change that E (I assume that’s the search criteria) to search specific cells E1 to E12 or use the range E1:E12. I’ve tried to make the change but it will not work. Also, after each copy and paste of cell B30 etc. delete all contents in cell B30, C30, D30 etc.

    – NANCY SKYES
    Nov 14 '18 at 14:09











  • Yes, but where in column E should it go?

    – SJR
    Nov 14 '18 at 15:48











  • I'm getting there using VBA but I have a ways to go so please bear with me. So if I'm correct in saying that it searches column E for the correct cell i would say the range is E1:E12 or am I misunderstanding your question?

    – NANCY SKYES
    Nov 14 '18 at 16:27











  • In the code above, when found=1 the value in B30 is put in E1, and then F30 goes in E2 etc. What I'm asking is what determines the output cell? What are you searching E1:E12 for?

    – SJR
    Nov 14 '18 at 16:35











  • Sorry now I know what you're referring to. As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1).

    – NANCY SKYES
    Nov 14 '18 at 16:38














0












0








0







As I said, I can't follow what you're doing, but this will give you "7-16" in E1 if B30 contains 7-15 (and similarly for the other cells). I've stripped out most of your code so I don't know if this is a full answer



Sub master2()

Dim pair As Range, found As Variant, v As Variant

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = "15" Then
v = Split(pair, "-")
found = Application.Match(pair.Offset(1),Range("E1:E12"), 0)
If IsNumeric(found) Then
Range("F1:F12").Cells(found).Value = v(0) & "-" & v(1) + 1
End If
End If
Next pair

End Sub





share|improve this answer















As I said, I can't follow what you're doing, but this will give you "7-16" in E1 if B30 contains 7-15 (and similarly for the other cells). I've stripped out most of your code so I don't know if this is a full answer



Sub master2()

Dim pair As Range, found As Variant, v As Variant

For Each pair In Range("B30, F30, J30")
If Right(pair, 2) = "15" Then
v = Split(pair, "-")
found = Application.Match(pair.Offset(1),Range("E1:E12"), 0)
If IsNumeric(found) Then
Range("F1:F12").Cells(found).Value = v(0) & "-" & v(1) + 1
End If
End If
Next pair

End Sub






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 14 '18 at 21:57

























answered Nov 13 '18 at 21:14









SJRSJR

12.2k31217




12.2k31217













  • I tested your code and it works but I need the rest of the code to make it all work. The great news is I think you may have helped me to solve the problem on my own. If you can bear with me and if I can ask for, I hope, a small amount of help we might be done here. In my original code the line “Range("E" & found).Value = pair” can we change that E (I assume that’s the search criteria) to search specific cells E1 to E12 or use the range E1:E12. I’ve tried to make the change but it will not work. Also, after each copy and paste of cell B30 etc. delete all contents in cell B30, C30, D30 etc.

    – NANCY SKYES
    Nov 14 '18 at 14:09











  • Yes, but where in column E should it go?

    – SJR
    Nov 14 '18 at 15:48











  • I'm getting there using VBA but I have a ways to go so please bear with me. So if I'm correct in saying that it searches column E for the correct cell i would say the range is E1:E12 or am I misunderstanding your question?

    – NANCY SKYES
    Nov 14 '18 at 16:27











  • In the code above, when found=1 the value in B30 is put in E1, and then F30 goes in E2 etc. What I'm asking is what determines the output cell? What are you searching E1:E12 for?

    – SJR
    Nov 14 '18 at 16:35











  • Sorry now I know what you're referring to. As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1).

    – NANCY SKYES
    Nov 14 '18 at 16:38



















  • I tested your code and it works but I need the rest of the code to make it all work. The great news is I think you may have helped me to solve the problem on my own. If you can bear with me and if I can ask for, I hope, a small amount of help we might be done here. In my original code the line “Range("E" & found).Value = pair” can we change that E (I assume that’s the search criteria) to search specific cells E1 to E12 or use the range E1:E12. I’ve tried to make the change but it will not work. Also, after each copy and paste of cell B30 etc. delete all contents in cell B30, C30, D30 etc.

    – NANCY SKYES
    Nov 14 '18 at 14:09











  • Yes, but where in column E should it go?

    – SJR
    Nov 14 '18 at 15:48











  • I'm getting there using VBA but I have a ways to go so please bear with me. So if I'm correct in saying that it searches column E for the correct cell i would say the range is E1:E12 or am I misunderstanding your question?

    – NANCY SKYES
    Nov 14 '18 at 16:27











  • In the code above, when found=1 the value in B30 is put in E1, and then F30 goes in E2 etc. What I'm asking is what determines the output cell? What are you searching E1:E12 for?

    – SJR
    Nov 14 '18 at 16:35











  • Sorry now I know what you're referring to. As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1).

    – NANCY SKYES
    Nov 14 '18 at 16:38

















I tested your code and it works but I need the rest of the code to make it all work. The great news is I think you may have helped me to solve the problem on my own. If you can bear with me and if I can ask for, I hope, a small amount of help we might be done here. In my original code the line “Range("E" & found).Value = pair” can we change that E (I assume that’s the search criteria) to search specific cells E1 to E12 or use the range E1:E12. I’ve tried to make the change but it will not work. Also, after each copy and paste of cell B30 etc. delete all contents in cell B30, C30, D30 etc.

– NANCY SKYES
Nov 14 '18 at 14:09





I tested your code and it works but I need the rest of the code to make it all work. The great news is I think you may have helped me to solve the problem on my own. If you can bear with me and if I can ask for, I hope, a small amount of help we might be done here. In my original code the line “Range("E" & found).Value = pair” can we change that E (I assume that’s the search criteria) to search specific cells E1 to E12 or use the range E1:E12. I’ve tried to make the change but it will not work. Also, after each copy and paste of cell B30 etc. delete all contents in cell B30, C30, D30 etc.

– NANCY SKYES
Nov 14 '18 at 14:09













Yes, but where in column E should it go?

– SJR
Nov 14 '18 at 15:48





Yes, but where in column E should it go?

– SJR
Nov 14 '18 at 15:48













I'm getting there using VBA but I have a ways to go so please bear with me. So if I'm correct in saying that it searches column E for the correct cell i would say the range is E1:E12 or am I misunderstanding your question?

– NANCY SKYES
Nov 14 '18 at 16:27





I'm getting there using VBA but I have a ways to go so please bear with me. So if I'm correct in saying that it searches column E for the correct cell i would say the range is E1:E12 or am I misunderstanding your question?

– NANCY SKYES
Nov 14 '18 at 16:27













In the code above, when found=1 the value in B30 is put in E1, and then F30 goes in E2 etc. What I'm asking is what determines the output cell? What are you searching E1:E12 for?

– SJR
Nov 14 '18 at 16:35





In the code above, when found=1 the value in B30 is put in E1, and then F30 goes in E2 etc. What I'm asking is what determines the output cell? What are you searching E1:E12 for?

– SJR
Nov 14 '18 at 16:35













Sorry now I know what you're referring to. As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1).

– NANCY SKYES
Nov 14 '18 at 16:38





Sorry now I know what you're referring to. As per my Excel image, my macro is suppose to find specified cells that contain a 15 as the last number. Cell B30 has the number 7-15 in it. I need the macro to go to the cell below (B31 and use the number 1 in this example) and then search the following cell range: E1:E12 to find a 1 (cell E1). Once found place the 7-15 and increase the last digit by 1 (so it becomes 7-16) in the adjacent cell to the right (F1).

– NANCY SKYES
Nov 14 '18 at 16:38


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53287765%2fmacro-does-not-do-all-the-functions-it-s-suppose-to-do%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values