Problem with adding line in macro

asmales

New Member
Joined
Jul 2, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I am not an expert at excel macros and I am at a loss as to how to go forward.
I have attached the part of the spreadsheet and the macro written so far. When I have entered data into rows I3 to M3 I have no problem.
When I Pressthe macro to enter the data into the information set below it enters it into Row 20 I3 to M3, which a want. If I repeat this again a number of times it will keep adding the rows and eventually enter over the TOTAL row in row 22.
I want to be able to move the row with the TOTAL (row 20) down after each transaction to prevent this from happening.
As I enter a number of rows I want the total (which shows in row I22 to auto sum the number of rows that have been entered.

I have tried numerous ways but it is beyond me.


Sub SalesTransaction()

Worksheets("GENERAL SALES").Unprotect "AMBIT1ON"

Set wsSALES = Worksheets("GENERAL SALES")

With wsSALES

Set rng = .Range("I3:I29").Find(.Range("I3").Value, , , xlWhole).Offset(8, 0)

tmprow = rng.End(xlDown).Row

If tmprow = Rows.Count Then

tmprow = .Range("I" & Rows.Count).End(xlUp).Row + 1

ElseIf .Range("I" & tmprow).Value = "CODE" Then

tmprow = .Range("I" & tmprow).End(xlUp).Row + 1

ElseIf rng.Value <> "" Then

tmprow = rng.End(xlDown).Row + 1

End If

.Range("I" & tmprow & ":J" & tmprow & ":K" & tmprow & ":L" & tmprow & ":M" & tmprow) = Range("I3:M3").Value

End With

Range("I3").ClearContents
Range("J3").ClearContents

Range("L3").ClearContents

End Sub

Since this the first time that I have used this post thread forgive me if I make a mess of this
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
asmales I am not saying somebody here can't help you with the information you have given but, in my experience, it is better to download that XL2BB app and then just show us on a spreadsheet what it is you want to do. You could include your program if you like.
 
Upvote 0

Forum statistics

Threads
1,215,133
Messages
6,123,231
Members
449,091
Latest member
jeremy_bp001

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