HUh? Don't understand why marco not working...

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
Hi, can someone exlpain to me why isn't it working?
I tried to change
newWB2.Sheets("Order Template").Range("D79:F79").Select
to
newWB2.Sheets("Order Template").Range("R" & nTotal & "C:R" & nTotal & "C").Select




Rich (BB code):
newWB2.Sheets("Order Template").Range("c3").Value = "=COUNTA(A:A)"
        nCus = newWB2.Sheets("Order Template").Range("c3").Value
        nTotal = nCus + 1
 
newWB2.Sheets("Order Template").Range("D79:F79").Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        Selection.Borders(xlEdgeLeft).LineStyle = xlNone
        With Selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        With Selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = xlAutomatic
        End With
        Selection.Borders(xlEdgeRight).LineStyle = xlNone
        Selection.Borders(xlInsideVertical).LineStyle = xlNone
        newWB2.Sheets("Sheet2").Delete
        newWB2.Sheets("Sheet3").Delete
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Looks like you're trying to use R1C1 notation when you can refer to the range directly:

Code:
newWB2.Sheets("Order Template").Range("D" & nTotal & ":F" & nTotal).Select

HTH,
 
Upvote 0
thanks for the reply...I was stuck in this situation...

The columns isn't fixed. That's why I'm using R1C1 notation, cos they automatically define the columns for you...
For example it always starts at column D, but may not always end at column F. If the data expands until X, it'll be
newWB2.Sheets("Order Template").Range("D" & nTotal & ":X" & nTotal).Select

I tried to replace X with a number, but the formula doesn't work. Any idea how can I get around with this?
 
Upvote 0
Code:
newWB2.Sheets("Order Template").[D1].offset(nTotal-1,0).resize(1,X-3).Select
Regards
Northwolves
 
Upvote 0
THanks the for reply!

Didn't start a new topic because it's linked.
How do I insert an empty row right after that?
is it...offset...then .value = "" ?
 
Upvote 0
THanks the for reply!

Didn't start a new topic because it's linked.
How do I insert an empty row right after that?
is it...offset...then .value = "" ?

Code:
newWB2.Sheets("Order Template").[D1].Offset(nTotal - 1, 0).Resize(1, X - 3).Select
Selection.Offset(1, 0).EntireRow.Insert Shift:=xlDown

Regards
Northwolves
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

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